Part Number Hot Search : 
FBP08 GM71V 100LV HPR122 BA7652AF SI443 DB1501 96547
Product Description
Full Text Search
 

To Download MC68HC12BE32VFU8 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  motorola.com/semiconductors m68hc12 microcontrollers m68hc12b rev. 9 m68hc12b family data sheet 6/2004

m68hc12b family ? rev. 9.0 data sheet motorola 3 motorola and the stylized m logo are registered trademarks of motorola, inc. digitaldna is a trademark of motorola, inc. this product incorporates superflash? technol ogy licensed from sst. ? motorola, inc., 2004 m68hc12b family data sheet to provide the most up-to-date information, the revision of our documents on the world wide web will be the most current. your printed copy may be an earlier revision. to verify you have the latest information available, refer to: http://motorola.com/semiconductors the following revision history table summarizes changes contained in this document. for your convenience, the page number designators have been linked to the appropriate location.
revision history data sheet m68hc12b family ? rev. 9.0 4 revision history motorola revision history date revision level description page number(s) june, 2001 2.0 figure 1-7. bdm tool connector ? added nc (no connect) designator to pin 3 30 figure 18-16. bdm tool connector ? added nc designator to pin 3 334 table 14-2. loop mode functions ? corrected table header, third column, from ddrs1 to dds1 208 woms bit description, fifth line, changed (via ddrs0/2) to (via dds0/2) 208 ssoe bit description, second line, changed ddrs7 to dds7 218 in the table notes following the spc0 bit description, corrected bit designators from ddrs4, ddrs5, ddrs6, and ddrs7 to dds4, dds5, dds6, and dds7. 218 september, 2001 3.0 table 13-3. prescaler selection ? added value column and updated prescale factors 183 19.11 eeprom characteristics ? corrected minimum and maximum values for programming and erase times 341 april, 2002 4.0 document type changed from advance information to technical data reflecting qualification. n/a figure 3-9. condition code register (ccr) ? reset value for s bit corrected from u to 1 65 january, 2003 5.0 14.2.3.3 sci control register 2 ? removed erroneous reference to port s bit 3 in the definition for the transmitter enable bit (te). 209 figure 14-20. port s data register (ports) ? removed erroneous pin function for ps3 and ps2. 221 reformatted to meet publication standards n/a april, 2003 6.0 19.2 maximum ratings ? corrected maximum values for v dd , v dda , v ddx , and v in 335 19.7 atd maximum ratings ? corrected maximum values for v rh and v rl 339 figure 19-1. programming voltage envelope ? corrected maximum values for v fp and v dd 343 may, 2003 7.0 19.12.1 programming vo ltage supply envelope ? added subsection for clarity. 342 19.12.2 example v fp protection circuitry ? added subsection for clarity. 343 july, 2003 8.0 19.2 maximum ratings ? updated values 335 19.7 atd maximum ratings ? updated values 339 june, 2004 9.0 table 13-3. prescaler selection ? corrected prescaler factor for values 6 and 7 183
m68hc12b family ? rev. 9.0 data sheet motorola list of sections 5 data sheet ? m68hc12b family list of sections section 1. general description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19 section 2. register block. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 section 3. central processor un it (cpu) . . . . . . . . . . . . . . . . . . . . . . . 61 section 4. resets and interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 section 5. operating modes and resource mapp ing . . . . . . . . . . . . . 77 section 6. bus control and i nput/output (i/o) . . . . . . . . . . . . . . . . . . . 87 section 7. eeprom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 section 8. flash eeprom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 section 9. read-only memory (rom) . . . . . . . . . . . . . . . . . . . . . . . . . 117 section 10. clock generation m odule (cgm). . . . . . . . . . . . . . . . . . . 119 section 11. pulse-width modul ator (pwm). . . . . . . . . . . . . . . . . . . . . 133 section 12. standard timer module (tim) . . . . . . . . . . . . . . . . . . . . . 149 section 13. enhanced capture timer (ect ) module . . . . . . . . . . . . . 169 section 14. serial interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 section 15. byte data link communicati ons (bdlc) . . . . . . . . . . . . 227 section 16. mscan12 controller. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263 section 17. analog-to-digital converter (atd) . . . . . . . . . . . . . . . . . 301 section 18. development support . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315 section 19. electrical specifications. . . . . . . . . . . . . . . . . . . . . . . . . . 335 section 20. mechanical sp ecifications . . . . . . . . . . . . . . . . . . . . . . . . 359
list of sections data sheet m68hc12b family ? rev. 9.0 6 list of sections motorola
m68hc12b family ? rev. 9.0 data sheet motorola table of contents 7 data sheet ? m68hc12b family table of contents section 1. gener al description 1.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 1.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 1.3 slow-mode clock divider advisory. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 1.4 block diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 1.5 ordering information. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 1.6 pinout and signal descriptions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 1.6.1 pin assignments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 1.6.2 power supply pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 1.6.2.1 v dd and v ss . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 1.6.2.2 v ddx and v ssx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 1.6.2.3 v dda and v ssa . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 1.6.2.4 v rh and v rl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 1.6.2.5 v fp (mc68hc912b32 and mc68hc912bc32 only) . . . . . . . . . . 27 1.6.3 signal descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 1.6.3.1 xtal and extal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 1.6.3.2 eclk. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 1.6.3.3 reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 1.6.3.4 irq . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 1.6.3.5 xirq . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 1.6.3.6 smodn, moda, and modb . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 1.6.3.7 bkgd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 1.6.3.8 addr15?addr0 and data15?data0. . . . . . . . . . . . . . . . . . . . 31 1.6.3.9 r/w . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 1.6.3.10 lstrb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 1.6.3.11 ipipe1 and ipipe0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 1.6.3.12 dbe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 1.6.4 port signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 1.6.4.1 port a . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 1.6.4.2 port b . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 1.6.4.3 port e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 1.6.4.4 port dlc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 1.6.4.5 port can . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 1.6.4.6 port ad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 1.6.4.7 port p . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 1.6.4.8 port t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 1.6.4.9 port s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 1.6.5 port pullup, pulldown, and reduced drive. . . . . . . . . . . . . . . . . . . . 37
table of contents data sheet m68hc12b family ? rev. 9.0 8 table of contents motorola section 2. re gister block 2.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 2.2 registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 section 3. central processor un it (cpu) 3.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 3.2 programming model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 3.3 cpu registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 3.3.1 accumulators a and b . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 3.3.2 accumulator d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 3.3.3 index registers x and y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 3.3.4 stack pointer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 3.3.5 program counter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 3.3.6 condition code register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 3.4 data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 3.5 addressing modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 3.6 indexed addressing modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 3.7 opcodes and operands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 section 4. resets and interrupts 4.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 4.2 exception priority . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 4.3 maskable interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 4.4 latching of interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 4.5 interrupt control and priority registers . . . . . . . . . . . . . . . . . . . . . . . . . 72 4.5.1 interrupt control register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 4.5.2 highest priority i interrupt register. . . . . . . . . . . . . . . . . . . . . . . . . . 73 4.6 resets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 4.6.1 power-on reset (por) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 4.6.2 external reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 4.6.3 computer operating properly (cop) reset . . . . . . . . . . . . . . . . . . . 74 4.6.4 clock monitor reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 4.7 effects of reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 4.7.1 operating mode and memory map . . . . . . . . . . . . . . . . . . . . . . . . . . 74 4.7.2 clock and watchdog control logic . . . . . . . . . . . . . . . . . . . . . . . . . 74 4.7.3 interrupts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 4.7.4 parallel input/output (i/o). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 4.7.5 central processing unit (cpu) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 4.7.6 memory. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 4.7.7 other resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 4.8 interrupt recognition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
table of contents m68hc12b family ? rev. 9.0 data sheet motorola table of contents 9 section 5. operating modes and resource mapping 5.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 5.2 operating modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 5.2.1 normal operating modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 5.2.1.1 normal expanded wide mode . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 5.2.1.2 normal expanded narrow mode . . . . . . . . . . . . . . . . . . . . . . . . . . 78 5.2.1.3 normal single-chip mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 5.2.2 special operating modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 5.2.2.1 special expanded wide mode . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 5.2.2.2 special expanded narrow mode. . . . . . . . . . . . . . . . . . . . . . . . . . 79 5.2.2.3 special single-chip mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 5.2.2.4 special peripheral mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 5.2.3 background debug mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 5.3 internal resource mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 5.4 mode and resource mapping registers . . . . . . . . . . . . . . . . . . . . . . . . 80 5.4.1 mode register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 5.4.2 register initialization register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 5.4.3 ram initialization register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 5.4.4 eeprom initialization register . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 5.4.5 miscellaneous mapping control register . . . . . . . . . . . . . . . . . . . . . 84 5.5 memory map. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 section 6. bus contro l and input/output (i/o) 6.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 6.2 detecting access type from external sign als . . . . . . . . . . . . . . . . . . . . 87 6.3 registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 6.3.1 port a data register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 6.3.2 port a data direction register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 6.3.3 port b data register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 6.3.4 port b data direction register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 6.3.5 port e data register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 6.3.6 port e data direction register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 6.3.7 port e assignment register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 6.3.8 pullup control register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 6.3.9 reduced drive of i/o lines. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 section 7. eeprom 7.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 7.2 eeprom programmer?s model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 7.3 eeprom control registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 7.3.1 eeprom module configuration register. . . . . . . . . . . . . . . . . . . . . 99 7.3.2 eeprom block protect register . . . . . . . . . . . . . . . . . . . . . . . . . . 100 7.3.3 eeprom test register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 7.3.4 eeprom control register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
table of contents data sheet m68hc12b family ? rev. 9.0 10 table of contents motorola section 8. flash eeprom 8.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 8.2 flash eeprom array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 8.3 flash eeprom registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 8.3.1 flash eeprom lock control register . . . . . . . . . . . . . . . . . . . . 106 8.3.2 flash eeprom module configuration register . . . . . . . . . . . . . 106 8.3.3 flash eeprom module test register . . . . . . . . . . . . . . . . . . . . 107 8.3.4 flash eeprom control register. . . . . . . . . . . . . . . . . . . . . . . . . 108 8.4 operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 8.4.1 bootstrap operation single-chip mode . . . . . . . . . . . . . . . . . . . . . 109 8.4.2 normal operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 8.4.3 program/erase operation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 8.4.3.1 read/write accesses during program/erase . . . . . . . . . . . . . . . 110 8.4.3.2 program/erase verification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 8.4.3.3 program/erase sequence. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 8.5 programming the flash eeprom . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 8.6 erasing the flash eeprom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 8.7 program/erase protection interlocks . . . . . . . . . . . . . . . . . . . . . . . . . . 116 8.8 stop or wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 8.9 test mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 section 9. read-on ly memory (rom) 9.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 9.2 rom array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 section 10. clock gene ration module (cgm) 10.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 10.2 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 10.3 register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 10.4 clock selection and generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 10.5 slow mode divider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 10.6 clock functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 10.6.1 computer operating properly (cop) . . . . . . . . . . . . . . . . . . . . . . . 122 10.6.2 real-time interrupt. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 10.6.3 clock monitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 10.7 clock registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 10.7.1 slow mode divider register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 10.7.2 real-time interrupt control register . . . . . . . . . . . . . . . . . . . . . . . 124 10.7.3 real-time interrupt flag r egister . . . . . . . . . . . . . . . . . . . . . . . . . 125 10.7.4 cop control register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 10.7.5 arm/reset cop timer register . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 10.8 clock divider chains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
table of contents m68hc12b family ? rev. 9.0 data sheet motorola table of contents 11 section 11. pulse-wi dth modulator (pwm) 11.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 11.2 pwm register descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 11.2.1 pwm clocks and concatenate register . . . . . . . . . . . . . . . . . . . . 135 11.2.2 pwm clock select and polarity register . . . . . . . . . . . . . . . . . . . . 136 11.2.3 pwm enable register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 11.2.4 pwm prescale counter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 11.2.5 pwm scale register 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 11.2.6 pwm scale counter 0 value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 11.2.7 pwm scale register 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 11.2.8 pwm scale counter 1 value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 11.2.9 pwm channel counters 0?3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 11.2.10 pwm channel period registers 0?3 . . . . . . . . . . . . . . . . . . . . . . . 142 11.2.11 pwm channel duty registers 0?3 . . . . . . . . . . . . . . . . . . . . . . . . . 143 11.2.12 pwm control register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 11.2.13 pwm special mode register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 11.2.14 port p data register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 11.2.15 port p data direction register . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146 11.3 pwm boundary cases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146 11.4 using the output compare 7 feature to generate a pwm . . . . . . . . . 146 11.4.1 pwm period calculation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 11.4.2 equipment. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 11.4.3 code listing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 section 12. standard timer module (tim) 12.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 12.2 timer registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 12.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 12.3.1 timer input capture/output compare select register. . . . . . . . . . 151 12.3.2 timer compare force register . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 12.3.3 output compare 7 mask register . . . . . . . . . . . . . . . . . . . . . . . . . 152 12.3.4 output compare 7 data register . . . . . . . . . . . . . . . . . . . . . . . . . . 152 12.3.5 timer count register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 12.3.6 timer system control register. . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 12.3.7 timer control registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 12.3.8 timer interrupt mask registers . . . . . . . . . . . . . . . . . . . . . . . . . . . 156 12.3.9 timer interrupt flag registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 12.3.10 timer input capture/output compare registers . . . . . . . . . . . . . . 158 12.3.11 pulse accumulator contro l register. . . . . . . . . . . . . . . . . . . . . . . . 161 12.3.12 pulse accumulator flag register . . . . . . . . . . . . . . . . . . . . . . . . . . 163 12.3.13 16-bit pulse accumulator count register . . . . . . . . . . . . . . . . . . . 163 12.3.14 timer test register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 12.3.15 timer port data register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 12.3.16 data direction register for timer port . . . . . . . . . . . . . . . . . . . . . . 165 12.4 timer operation in modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
table of contents data sheet m68hc12b family ? rev. 9.0 12 table of contents motorola 12.5 using the output compare function to generate a square wave . . . 166 12.5.1 sample calculation to obtain period counts . . . . . . . . . . . . . . . . . 166 12.5.2 equipment. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166 12.5.3 code listing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 section 13. enhanced capt ure timer (ect) module 13.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 13.2 basic timer overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 13.3 enhanced capture timer modes of operatio n . . . . . . . . . . . . . . . . . . . 169 13.3.1 ic channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 13.3.1.1 non-buffered ic channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 13.3.1.2 buffered ic channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 13.3.2 pulse accumulators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 13.3.2.1 pulse accumulator latch mode . . . . . . . . . . . . . . . . . . . . . . . . . 171 13.3.2.2 pulse accumulator que ue mode . . . . . . . . . . . . . . . . . . . . . . . . 171 13.3.3 modulus down-counter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 13.4 timer registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 13.4.1 timer input capture/output compare select register. . . . . . . . . . 176 13.4.2 timer compare force register . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 13.4.3 output compare 7 mask register . . . . . . . . . . . . . . . . . . . . . . . . . 177 13.4.4 output compare 7 data register . . . . . . . . . . . . . . . . . . . . . . . . . . 178 13.4.5 timer count registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 13.4.6 timer system control register. . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 13.4.7 timer control registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 13.4.8 timer interrupt mask registers . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 13.4.9 main timer interrupt flag registers . . . . . . . . . . . . . . . . . . . . . . . . 183 13.4.10 timer input capture/output compare registers . . . . . . . . . . . . . . 185 13.4.11 16-bit pulse accumulator a control re gister . . . . . . . . . . . . . . . . . 188 13.4.12 pulse accumulator a flag register . . . . . . . . . . . . . . . . . . . . . . . . 189 13.4.13 pulse accumulators coun t registers . . . . . . . . . . . . . . . . . . . . . . . 190 13.4.14 16-bit modulus down-counter control register. . . . . . . . . . . . . . . 191 13.4.15 16-bit modulus down-counter flag register . . . . . . . . . . . . . . . . . 192 13.4.16 input control pulse accumulators c ontrol register . . . . . . . . . . . . 193 13.4.17 delay counter control register . . . . . . . . . . . . . . . . . . . . . . . . . . . 193 13.4.18 input control overwrite register . . . . . . . . . . . . . . . . . . . . . . . . . . 194 13.4.19 input control system control register . . . . . . . . . . . . . . . . . . . . . . 194 13.4.20 timer test register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 13.4.21 timer port data register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 13.4.22 data direction register for timer port . . . . . . . . . . . . . . . . . . . . . . 197 13.4.23 16-bit pulse accumulator b control re gister . . . . . . . . . . . . . . . . . 197 13.4.24 pulse accumulator b flag register . . . . . . . . . . . . . . . . . . . . . . . . 198 13.4.25 8-bit pulse accumulators holding regi sters . . . . . . . . . . . . . . . . . 198 13.4.26 modulus down-counter count registers . . . . . . . . . . . . . . . . . . . . 199 13.4.27 timer input capture holding registers . . . . . . . . . . . . . . . . . . . . . 200 13.5 timer and modulus counter operation in different modes . . . . . . . . . 202
table of contents m68hc12b family ? rev. 9.0 data sheet motorola table of contents 13 section 14. serial interface 14.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 14.2 serial communication interfac e (sci) . . . . . . . . . . . . . . . . . . . . . . . . . 204 14.2.1 data format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204 14.2.2 sci baud rate generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 14.2.3 sci register descriptions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 14.2.3.1 sci baud rate control register . . . . . . . . . . . . . . . . . . . . . . . . . 206 14.2.3.2 sci control register 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 14.2.3.3 sci control register 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209 14.2.3.4 sci status register 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210 14.2.3.5 sci status register 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212 14.2.3.6 sci data register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213 14.3 serial peripheral interface (spi) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 14.3.1 spi baud rate generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 14.3.2 spi operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 14.3.3 ss output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216 14.3.4 bidirectional mode (momi or siso) . . . . . . . . . . . . . . . . . . . . . . . . 216 14.3.5 spi register descriptions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217 14.3.5.1 spi control register 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217 14.3.5.2 spi control register 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218 14.3.5.3 spi baud rate register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 14.3.5.4 spi status register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220 14.3.5.5 spi data register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221 14.4 port s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221 14.4.1 port s data register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221 14.4.2 port s data direction register . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222 14.4.3 pullup and reduced drive register for port s . . . . . . . . . . . . . . . . 223 14.5 serial character transmission using the sc i. . . . . . . . . . . . . . . . . . . . 224 14.5.1 equipment. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224 14.5.2 code listing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224 14.6 synchronous character transmission usin g the spi . . . . . . . . . . . . . . 225 14.6.1 equipment. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225 14.6.2 code listing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225 section 15. byte data link communications (bdlc) 15.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227 15.2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227 15.3 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228 15.4 bdlc operating modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229 15.4.1 power off mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229 15.4.2 reset mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229 15.4.3 run mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230 15.5 power-conserving modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230 15.5.1 bdlc wait and cpu wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . 231 15.5.2 bdlc stop and cpu wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . 231 15.5.3 bdlc stop and cpu stop mode . . . . . . . . . . . . . . . . . . . . . . . . . . 232
table of contents data sheet m68hc12b family ? rev. 9.0 14 table of contents motorola 15.6 loopback modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232 15.6.0.1 digital loopback mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232 15.6.0.2 analog loopback mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232 15.7 bdlc mux interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233 15.7.1 rx digital filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233 15.7.1.1 operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233 15.7.1.2 performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234 15.7.2 j1850 frame format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235 15.7.2.1 sof ? start-of-frame symbol . . . . . . . . . . . . . . . . . . . . . . . . . . 235 15.7.2.2 data ? in-message data bytes . . . . . . . . . . . . . . . . . . . . . . . . . 235 15.7.2.3 crc ? cyclical redun dancy check byte . . . . . . . . . . . . . . . . . 235 15.7.2.4 eod ? end-of-data symbol . . . . . . . . . . . . . . . . . . . . . . . . . . . 236 15.7.2.5 ifr ? in-frame response bytes . . . . . . . . . . . . . . . . . . . . . . . . 236 15.7.2.6 eof ? end-of-frame symbol . . . . . . . . . . . . . . . . . . . . . . . . . . 236 15.7.2.7 ifs ? interframe separation symbol . . . . . . . . . . . . . . . . . . . . . 236 15.7.2.8 break ? break . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237 15.7.2.9 idle ? idle bus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237 15.7.3 j1850 vpw symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237 15.7.3.1 logic 0. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238 15.7.3.2 logic 1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239 15.7.3.3 normalization bit (nb). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239 15.7.3.4 break signal (break) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239 15.7.3.5 start-of-frame symbol (sof) . . . . . . . . . . . . . . . . . . . . . . . . . . . 239 15.7.3.6 end-of-data symbol (eod). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239 15.7.3.7 end-of-frame symbol (eof) . . . . . . . . . . . . . . . . . . . . . . . . . . . 239 15.7.3.8 inter-frame separation symbol (ifs) . . . . . . . . . . . . . . . . . . . . . 239 15.7.3.9 idle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239 15.7.4 j1850 vpw valid/invalid bits and symbols . . . . . . . . . . . . . . . . . . 240 15.7.4.1 invalid passive bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241 15.7.4.2 valid passive logic 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241 15.7.4.3 valid passive logic 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241 15.7.4.4 valid eod symbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241 15.7.4.5 valid eof and ifs symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242 15.7.4.6 idle bus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242 15.7.4.7 invalid active bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 15.7.4.8 valid active logic 1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 15.7.4.9 valid active logic 0. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 15.7.4.10 valid sof symbol. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 15.7.4.11 valid break symbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 15.7.5 message arbitration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244 15.8 bdlc protocol handler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245 15.8.1 protocol architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245 15.8.2 rx and tx shift registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246 15.8.3 rx and tx shadow registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246 15.8.4 digital loopback multiplexer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246
table of contents m68hc12b family ? rev. 9.0 data sheet motorola table of contents 15 15.8.5 state machine. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246 15.8.5.1 4x mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246 15.8.5.2 receiving a message in block mode . . . . . . . . . . . . . . . . . . . . . 246 15.8.5.3 transmitting a message in block mode . . . . . . . . . . . . . . . . . . . 247 15.8.5.4 j1850 bus errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247 15.8.5.5 summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248 15.9 bdlc registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249 15.9.1 bdlc control register 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249 15.9.2 bdlc control register 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250 15.9.3 bdlc state vector register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256 15.9.4 bdlc data register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258 15.9.5 bdlc analog roundtrip delay register. . . . . . . . . . . . . . . . . . . . . 259 15.9.6 port dlc control register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260 15.9.7 port dlc data register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261 15.9.8 port dlc data direction register. . . . . . . . . . . . . . . . . . . . . . . . . . 262 section 16. msca n12 controller 16.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263 16.2 external pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263 16.3 message storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264 16.3.1 background. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264 16.3.2 receive structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265 16.3.3 transmit structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267 16.4 identifier acceptance filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268 16.5 interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271 16.5.1 interrupt acknowledge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271 16.5.2 interrupt vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272 16.6 protocol violation protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272 16.7 low-power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273 16.7.1 mscan12 sleep mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273 16.7.2 mscan12 soft-reset mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275 16.7.3 mscan12 power-down mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275 16.7.4 programmable wakeup function . . . . . . . . . . . . . . . . . . . . . . . . . . 275 16.8 timer link . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276 16.9 clock system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276 16.10 memory map. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279 16.11 programmer?s model of message storage . . . . . . . . . . . . . . . . . . . . . . 279 16.11.1 message buffer organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279 16.11.2 identifier registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280 16.11.3 data length register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282 16.11.4 data segment registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283 16.11.5 transmit buffer priority register. . . . . . . . . . . . . . . . . . . . . . . . . . . 284 16.12 programmer?s model of control registers . . . . . . . . . . . . . . . . . . . . . . 284 16.12.1 mscan12 module control register 0. . . . . . . . . . . . . . . . . . . . . . . 284 16.12.2 mscan12 module control register1 . . . . . . . . . . . . . . . . . . . . . . . 286 16.12.3 mscan12 bus timing register 0 . . . . . . . . . . . . . . . . . . . . . . . . . . 287
table of contents data sheet m68hc12b family ? rev. 9.0 16 table of contents motorola 16.12.4 mscan12 bus timing register 1 . . . . . . . . . . . . . . . . . . . . . . . . . . 288 16.12.5 mscan12 receiver flag register . . . . . . . . . . . . . . . . . . . . . . . . . 289 16.12.6 mscan12 receiver interrupt enable register . . . . . . . . . . . . . . . . 291 16.12.7 mscan12 transmitter flag register . . . . . . . . . . . . . . . . . . . . . . . 292 16.12.8 mscan12 transmitter control register . . . . . . . . . . . . . . . . . . . . . 293 16.12.9 mscan12 identifier acceptance contro l register . . . . . . . . . . . . . 294 16.12.10 mscan12 receive error counter. . . . . . . . . . . . . . . . . . . . . . . . . . 295 16.12.11 mscan12 transmit error counter . . . . . . . . . . . . . . . . . . . . . . . . . 295 16.12.12 mscan12 identifier acceptance register s. . . . . . . . . . . . . . . . . . . 295 16.12.13 mscan12 identifier mask registers. . . . . . . . . . . . . . . . . . . . . . . . 297 16.12.14 mscan12 port can control register . . . . . . . . . . . . . . . . . . . . . . 299 16.12.15 mscan12 port can data register . . . . . . . . . . . . . . . . . . . . . . . . 299 16.12.16 mscan12 port can data direction r egister . . . . . . . . . . . . . . . . . 300 section 17. analog-to-d igital converter (atd) 17.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301 17.2 functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301 17.3 atd registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303 17.3.1 atd control register 0. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303 17.3.2 atd control register 1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303 17.3.3 atd control register 2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303 17.3.4 adt control register 3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304 17.3.5 atd control register 4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305 17.3.6 atd control register 5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307 17.3.7 atd status registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309 17.3.8 atd test registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310 17.3.9 port ad data input register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311 17.3.10 atd result registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311 17.4 atd mode operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312 17.5 using the atd to measure a potentiomete r signal . . . . . . . . . . . . . . . 313 17.5.1 equipment. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313 17.5.2 code listing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313 section 18. development support 18.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315 18.2 instruction queue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315 18.3 background debug mode (bdm) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316 18.3.1 bdm serial interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316 18.3.2 enabling bdm firmware commands . . . . . . . . . . . . . . . . . . . . . . . 319 18.3.3 bdm commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319 18.3.4 bdm registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322 18.3.5 bdm instruction register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323 18.3.5.1 hardware command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323 18.3.5.2 firmware command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324 18.3.6 bdm status register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325 18.3.7 bdm shifter register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326
table of contents m68hc12b family ? rev. 9.0 data sheet motorola table of contents 17 18.3.8 bdm address register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326 18.3.9 bdm ccr holding register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327 18.4 breakpoints. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327 18.4.1 breakpoint modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327 18.4.1.1 swi dual address mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328 18.4.1.2 bdm full breakpoint mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328 18.4.1.3 bdm dual address mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328 18.4.2 breakpoint registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329 18.4.2.1 breakpoint control register 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . 329 18.4.2.2 breakpoint control register 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . 330 18.4.2.3 breakpoint address register high . . . . . . . . . . . . . . . . . . . . . . . 332 18.4.2.4 breakpoint address register low . . . . . . . . . . . . . . . . . . . . . . . . 332 18.4.2.5 breakpoint data register high . . . . . . . . . . . . . . . . . . . . . . . . . . 332 18.4.2.6 breakpoint data register low byte . . . . . . . . . . . . . . . . . . . . . . 333 18.5 instruction tagging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333 section 19. electri cal specifications 19.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335 19.2 maximum ratings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335 19.3 functional operating range. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336 19.4 thermal characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336 19.5 5.0 volt dc electrical characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . 337 19.6 supply current . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338 19.7 atd maximum ratings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339 19.8 atd dc electrical characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339 19.9 analog converter operating characteristics . . . . . . . . . . . . . . . . . . . . 340 19.10 atd ac operating characteristics (operat ing) . . . . . . . . . . . . . . . . . . 341 19.11 eeprom characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341 19.12 flash eeprom characteristics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342 19.12.1 programming voltage supply envelope . . . . . . . . . . . . . . . . . . . . . 342 19.12.2 example v fp protection circuitry . . . . . . . . . . . . . . . . . . . . . . . . . . 343 19.13 pulse-width modulator charac teristics. . . . . . . . . . . . . . . . . . . . . . . . . 346 19.14 control timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347 19.15 peripheral port timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352 19.16 multiplexed expansion bus timing. . . . . . . . . . . . . . . . . . . . . . . . . . . . 353 19.17 serial peripheral interface (spi) timing . . . . . . . . . . . . . . . . . . . . . . . . 355 section 20. mechani cal specifications 20.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359 20.2 80-pin quad flat pack (case 841b-02) . . . . . . . . . . . . . . . . . . . . . . . . 360
table of contents data sheet m68hc12b family ? rev. 9.0 18 table of contents motorola
m68hc12b family ? rev. 9.0 data sheet motorola general description 19 data sheet ? m68hc12b family section 1. general description 1.1 introduction the mc68hc912b32, mc68hc12be32 and mc68hc(9)12bc32, are 16-bit microcontroller units (mcus) composed of standard on-chip peripherals. the multiplexed external bus can also operate in an 8-bit narrow mode for interfacing with single 8-bit wide memory in lower-cos t systems. there is a slight feature set difference between the four pin-for-pin compatible devices as shown in table 1-1 . table 1-1. m68hc12b series feature set comparisons features mc68hc912b32 mc68hc12be32 mc68hc912bc32 mc68hc12bc32 cpu12 x x x x multiplexed bus x x x x 32-kbyte flash electrically erasable, programmable read-only memory (eeprom) xx 32-kbyte read-only memory (rom) x x 768-byte eeprom x x x x 1-kbyte random-access memory (ram) x x x x analog-to-digital (a/d) converter x x x x standard timer module (tim) x x x enhanced capture timer (ect) x pulse-width modulator (pwm) x x x x asynchronous serial communications interface (scii) xx x x synchronous serial peripheral interface (spi) x x x x j1850 byte data link communication (bdlc) x x controller area network module (can) x x computer operating properly (cop) watchdog timer xx x x slow mode clock divider x x x x 80-pin quad flat pack (qfp) x x x x single-wire background debug mode (bdm) x x x x
general description data sheet m68hc12b family ? rev. 9.0 20 general description motorola 1.2 features features include:  16-bit cpu12: ? upwardly compatible with the m68hc11 instruction set ? interrupt stacking and programmer?s model identical to the m68hc11 ? 20-bit arithmetic logic unit (alu) ? instruction queue ? enhanced indexed addressing ? fuzzy logic instructions  multiplexed bus: ? single chip or expanded ? 16-bit by 16-bit wide or 16-bit by 8-bit narrow modes  memory: ? 32-kbyte flash electrically erasable, programmable read-only memory (eeprom) with 2-kbyte erase-protected boot block ? mc68hc912b32 and mc68hc912bc32 only ? 32-kbyte rom ? mc68hc12be32 and mc68hc12bc32 only ? 768-byte eeprom ? 1-kbyte random-access memory (r am) with single-cycle access for aligned or misaligned read/write  8-channel, 10-bit analog-to-digital converter (atd)  8-channel standard timer module (tim) ? mc68hc912b32 and mc68hc(9)12bc32 only: ? each channel fully conf igurable as either input capture or output compare ? simple pulse-width modulator (pwm) mode ? modulus reset of timer counter  enhanced capture timer (ect) ? mc68hc12be32 only: ? 16-bit main counter with 7-bit prescaler ? eight programmable input capture or output compare channels; four of the eight input captures with buffer ? input capture filters and buffers, three successive captures on four channels, or two captures on four channels with a capture/compare selectable on the remaining four ? four 8-bit or two 16-bit pulse accumulators ? 16-bit modulus down-counter with 4-bit prescaler ? four user-selectable delay counters for signal filtering
general description slow-mode clock divider advisory m68hc12b family ? rev. 9.0 data sheet motorola general description 21  16-bit pulse accumulator: ? external event counting ? gated time accumulation  pulse-width modulator (pwm): ? 8-bit, 4-channel or 16-bit, 2-channel ? separate control for each pulse width and duty cycle ? programmable center-aligned or left-aligned outputs  serial interfaces: ? asynchronous serial communications interface (sci) ? synchronous serial peripheral interface (spi) ? j1850 byte data link communication (bdlc), mc68hc912b32 and mc68hc12be32 only ? controller area network (can), mc68hc(9)12bc32 only  computer operating properly (cop) watchdog timer, clock monitor, and periodic interrupt timer  slow-mode clock divider  80-pin quad flat pack (qfp)  up to 63 general-purpose input/output (i/o) lines  single-wire background debug mode (bdm)  on-chip hardware breakpoints 1.3 slow-mode cloc k divider advisory current versions of the m68hc12b-series devices include a slow-mode clock divider feature. this feature is fully described in section 10. clock generation module (cgm) . the register that controls this feature is located at $00e0. older device mask sets do not support the slow-mode clock divider feature. this register address is reserved in older devices and provides no function. mask sets that do not have the slow -mode clock divider feature on the mc68hc912b32 include: g96p, g86w, and h91f. mask sets that do not have the slow -mode clock divider feature on the mc68hc12be32 include: h54t and j38m. mask sets that do not have the slow -mode clock divider feature on the mc68hc(9)12bc32 include: j15g.
general description data sheet m68hc12b family ? rev. 9.0 22 general description motorola 1.4 block diagrams figure 1-1. block diagram for mc68hc912b32 and mc68hc12be32 ioc0 ioc1 ioc2 ioc3 ioc4 ioc5 ioc6 pai oc7 ddrt port t periodic interrupt cop watchdog 32-kbyte flash eeprom/rom 1-kbyte ram port e timer and pt0 pt1 pt2 pt3 pt4 pt5 pt6 pt7 spi ddrs port s atd port ad pe1 pe2 pe4 pe5 pe6 pe3 pad3 pad4 pad5 pad6 pad7 v dda v ssa v rh v rl pad0 pad1 pad2 ddra port a ddrb port b pa4 pa3 pa2 pa1 pa0 pa7 pa6 pa5 pb4 pb3 pb2 pb1 pb0 pb7 pb6 pb5 data15 multiplexed address/data bus reset extal xtal pw0 pw1 pw2 pw3 pwm ddrp port p pp0 pp1 pp2 pp3 v dd 2 v ss 2 sci rxd txd i/o i/o sdi/miso sdo/mosi sck cs /ss ps0 ps1 ps2 ps3 ps4 ps5 ps6 ps7 768-byte eeprom clock monitor pe0 pe7 an3 an4 an5 an6 an7 v dda v ssa v rh v rl an0 an1 an2 single-wire background debug module smodn / taghi eclk r/w lstrb / taglo ipipe0 / moda ipipe1 / modb xirq dbe pulse accumulator lite pp4 pp5 pp6 pp7 i/o i/o i/o i/o i/o i/o dlctx dlcrx i/o bdlc ddrdlc port dlc pdlc4 pdlc5 pdlc6 i/o i/o i/o i/o pdlc0 pdlc1 pdlc2 pdlc3 integration module (lim) v fp break points cpu12 a d d r 1 5 a d d r 1 4 a d d r 1 3 a d d r 1 2 a d d r 1 1 a d d r 1 0 a d d r 9 a d d r 8 data14 data13 data12 data11 data10 data9 data8 a d d r 7 a d d r 6 a d d r 5 a d d r 4 a d d r 3 a d d r 2 a d d r 1 a d d r 0 data7 data6 data5 data4 data3 data2 data1 data0 i/o converter v ssx 2 v ddx 2 power for power for i/o drivers internal circuitry data7 data6 data5 data4 data3 data2 data1 data0 narrow bus wide bus bkgd irq /v pp
general description block diagrams m68hc12b family ? rev. 9.0 data sheet motorola general description 23 figure 1-2. block diagram for mc68hc(9)12bc32 ioc0 ioc1 ioc2 ioc3 ioc4 ioc5 ioc6 pai oc7 ddrt port t periodic interrupt cop watchdog 32-kbyte flash eeprom/rom 1-kbyte ram port e timer and pt0 pt1 pt2 pt3 pt4 pt5 pt6 pt7 spi ddrs port s atd port ad pe1 pe2 pe4 pe5 pe6 pe3 pad3 pad4 pad5 pad6 pad7 v dda v ssa v rh v rl pad0 pad1 pad2 ddra port a ddrb port b pa4 pa3 pa2 pa1 pa0 pa7 pa6 pa5 pb4 pb3 pb2 pb1 pb0 pb7 pb6 pb5 data15 multiplexed address/data bus reset extal xtal pw0 pw1 pw2 pw3 pwm ddrp port p pp0 pp1 pp2 pp3 v dd 2 v ss 2 sci rxd txd i/o i/o sdi/miso sdo/mosi sck cs /ss ps0 ps1 ps2 ps3 ps4 ps5 ps6 ps7 768-byte eeprom clock monitor pe0 pe7 an3 an4 an5 an6 an7 v dda v ssa v rh v rl an0 an1 an2 single-wire background debug module smodn / taghi eclk r/w lstrb / taglo ipipe0 / moda ipipe1 / modb xirq dbe pulse accumulator lite pp4 pp5 pp6 pp7 i/o i/o i/o i/o i/o i/o txcan rxcan i/o ddrcan port can pcan4 pcan5 pcan6 i/o i/o i/o i/o rxcan txcan pcan2 pcan3 integration module (lim) v fp break points cpu12 a d d r 1 5 a d d r 1 4 a d d r 1 3 a d d r 1 2 a d d r 1 1 a d d r 1 0 a d d r 9 a d d r 8 data14 data13 data12 data11 data10 data9 data8 a d d r 7 a d d r 6 a d d r 5 a d d r 4 a d d r 3 a d d r 2 a d d r 1 a d d r 0 data7 data6 data5 data4 data3 data2 data1 data0 i/o converter v ssx 2 v ddx 2 power for power for i/o drivers internal circuitry data7 data6 data5 data4 data3 data2 data1 data0 narrow bus wide bus bkgd irq /v pp mscan
general description data sheet m68hc12b family ? rev. 9.0 24 general description motorola 1.5 ordering information the m68hc12b-series devices are avail able in 80-pin quad flat pack (qfp) packaging and are shipped in 2-piece sample packs, 84-piece trays, or 420-piece bricks. operating temperature range, packa ge type, and voltage requirements are specified when ordering the specific device. documents to assist in product selection are available from the motorola literature distribution center or your local motorola sales offices. product selection guides can also be found on the worldwide web at this url: http://motorola.com/semiconductors/ evaluation boards, assemblers, compilers, and debuggers are available from motorola and from third-party suppliers. an up-to-date list of products that support the m68hc12 family of microcontrollers c an be found on the worldwide web at this url: http://motorola.com/semiconductors/ 1.6 pinout and signal descriptions 1.6.1 pin assignments the mcu is available in an 80-pin quad flat pack (qfp). figure 1-3 and figure 1-4 show the pin assignments. most pins perf orm two or more functions, as described in the 1.6.3 signal descriptions . 1.6.2 power supply pins the mcu power and ground pins are described here and summarized in table 1-2 . 1.6.2.1 v dd and v ss v dd and v ss are the internal power supply and ground pins. because fast signal transitions place high, short-duration current demands on the power supply, use bypass capacitors with high-frequency charac teristics and place them as close to the mcu as possible. bypass requir ements depend on how heavily the mcu pins are loaded.
general description pinout and signal descriptions m68hc12b family ? rev. 9.0 data sheet motorola general description 25 figure 1-3. pin assignments for mc68hc912b32 and mc68hc12be32 devices mc68hc912b32 80-pin qfp pp5 pp4 pw3 / pp3 pw2 / pp2 pw1/ pp1 41 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 40 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 pa2 / data10 / addr10 pa3 / data11 / addr11 pa4 / data12 / addr12 pa5 / data13 / addr13 pa6 / data14 / addr14 pa7 / data15 / addr15 pp6 pp7 addr0 / data0 / pb0 addr1 / data1 / pb1 addr2 / data2 / pb2 smodn / taghi / bkgd pai / ioc7 / pt7 ioc6 / pt6 ioc5 / pt5 ioc4 / pt4 ioc3 / pt3 ioc2 / pt2 ioc1 / pt1 ioc0 / pt0 addr9 / data9 / pa1 xirq / pe0 irq / pe1 r/w / pe2 lstrb / taglo / pe3 xtal extal reset v ddx v ssx eclk / pe4 moda / ipipe0 / pe5 modb / ipipe1 / pe6 dbe / pe7 addr7 / data7 / pb7 addr6 / data6 / pb6 addr5 / data5 / pb5 addr4 / data4 / pb4 addr3 / data3 / pb3 v dd v ss pw0/ pp0 v ssa v dda pad7 / an7 pad6 / an6 pad5 / an5 pad4 / an4 pad3 / an3 pad2 / an2 pad1 / an1 pad0 / an0 v rl v rh v ss v dd ps0 / rxd ps1 / txd ps2 ps3 ps4 / sdi/miso ps5 / sdo/mosi ps6 / sck ps7 / cs /ss v fp /nc (1) pdlc6 pdlc5 pdlc4 pdlc3 pdlc2 pdlc1 / dlctx pdlc0 / dlcrx v ssx v ddx addr8 / data8 / pa0 port ad port a (2) port b port e port e port dlc port s port p port t port t shaded pins are power and ground 1. pin 69 is an nc (no connect) on the mc68hc12be32. 2. in narrow mode, high and low data bytes are multiplexed in al ternate bus cycles on port a. notes:
general description data sheet m68hc12b family ? rev. 9.0 26 general description motorola figure 1-4. pin assignments for mc68hc(9)12bc32 devices mc68hc(9)12bc32 80-pin qfp pp5 pp4 pw3 / pp3 pw2 / pp2 pw1/ pp1 41 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 40 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 pa2 / data10 / addr10 pa3 / data11 / addr11 pa4 / data12 / addr12 pa5 / data13 / addr13 pa6 / data14 / addr14 pa7 / data15 / addr15 pp6 pp7 addr0 / data0 / pb0 addr1 / data1 / pb1 addr2 / data2 / pb2 smodn / taghi / bkgd pai / ioc7 / pt7 ioc6 / pt6 ioc5 / pt5 ioc4 / pt4 ioc3 / pt3 ioc2 / pt2 ioc1 / pt1 ioc0 / pt0 addr9 / data9 / pa1 xirq / pe0 irq / pe1 r/w / pe2 lstrb / taglo / pe3 xtal extal reset v ddx v ssx eclk / pe4 moda / ipipe0 / pe5 modb / ipipe1 / pe6 dbe / pe7 addr7 / data7 / pb7 addr6 / data6 / pb6 addr5 / data5 / pb5 addr4 / data4 / pb4 addr3 / data3 / pb3 v dd v ss pw0/ pp0 v ssa v dda pad7 / an7 pad6 / an6 pad5 / an5 pad4 / an4 pad3 / an3 pad2 / an2 pad1 / an1 pad0 / an0 v rl v rh v ss v dd ps0 / rxd ps1 / txd ps2 ps3 ps4 / sdi/miso ps5 / sdo/mosi ps6 / sck ps7 / cs /ss v fp /nc (1) pcan6 pcan5 pcan4 pcan3 pcan2 txcan rxcan v ssx v ddx addr8 / data8 / pa0 port ad port a (2) port b port e port e port can port s port p port t port t shaded pins are power and ground 1. pin 69 is an nc (no connect) on the mc68hc12bc32. 2. in narrow mode, high and low data bytes are multiplexed in al ternate bus cycles on port a. notes:
general description pinout and signal descriptions m68hc12b family ? rev. 9.0 data sheet motorola general description 27 1.6.2.2 v ddx and v ssx v ddx and v ssx are the external power supply and ground pins. because fast signal transitions place high, short-duration current demands on the power supply, use bypass capacitors with high-frequency charac teristics and place them as close to the mcu as possible. bypass requir ements depend on how heavily the mcu pins are loaded. 1.6.2.3 v dda and v ssa v dda and v ssa are the power supply and ground pins for the analog-to-digital converter (atd). this allows the s upply voltage to be bypassed independently. 1.6.2.4 v rh and v rl v rh and v rl are the reference voltage pins for the atd. 1.6.2.5 v fp (mc68hc912b32 and mc68hc912bc32 only) v fp is the flash eeprom programming voltage and supply voltage during normal operation for the mc68hc912b32 and mc68hc912bc32 only. table 1-2. power and ground connection summary mnemonic pin number description v dd 10, 47 internal power and ground v ss 11, 48 v ddx 31, 78 external power and ground supply to pin drivers v ssx 30, 77 v dda 59 operating voltage and ground for the atd; allows the supply voltage to be bypassed independently v ssa 60 v rh 49 reference voltages for the analog-to-digital converter v rl 50 v fp 69 programming voltage for the flash eeprom and required supply for normal operation ? mc68hc912b32 and mc68hc912bc32 only. pin 69 is a no connect (nc) on the mc68hc12be32 and mc68hc12bc32.
general description data sheet m68hc12b family ? rev. 9.0 28 general description motorola 1.6.3 signal descriptions the mcu signals are described here and summarized in table 1-3 . 1.6.3.1 xtal and extal xtal and extal are the crystal driver and external clock input pins. they provide the interface for either a crystal or a cmos compatible clock to control the internal clock generator circuitry. out of reset the frequency applied to extal is twice the desired e-clock rate. all the device cloc ks are derived from the extal input frequency. xtal is the crystal output. the xtal pin must be left unterminated when an external cmos compatible clock input is connected to the extal pin. the xtal output is normally intended to drive only a crystal. the xtal output can be buffered with a high-impedance buffer to drive the extal input of another device. note: in all cases, take extra care in the circuit board layout around the oscillator pins. load capacitances shown in the oscillator circuits include all stray layout capacitances. refer to figure 1-5 and figure 1-6 for diagrams of oscillator circuits. figure 1-5. common crystal connections figure 1-6. external oscillator connections 10 m ? mcu c c extal xtal 2 x e crystal nc mcu extal xtal 2 x e cmos-compatible external oscillator
general description pinout and signal descriptions m68hc12b family ? rev. 9.0 data sheet motorola general description 29 1.6.3.2 eclk eclk is the output connection for the inter nal bus clock and is used to demultiplex the address and data and is used as a ti ming reference. eclk frequency is equal to one half the crystal frequency out of reset. in normal single-chip mode, the e-clock output is off at reset to reduce the effects of radio frequency interference (rfi), but it can be turned on if necessary. in special single-chip mode, the e-clock output is on at reset but can be turned off. in special peripheral mode, the e clock is an input to the mcu. all clocks, including the e clock, are halt ed when the mcu is in stop mode. it is possible to configure the mcu to interface to slow external memory. eclk can be stretched for such accesses. 1.6.3.3 reset an active-low, bidirect ional control signal, reset is an input to initialize the mcu to a known startup state. it also acts as an open-drain output to indicate that an internal failure has been detected in either the clock monitor or cop watchdog circuit. the mcu goes into reset asynchronously and comes out of reset synchronously. this allows the part to reac h a proper reset state even if the clocks have failed, while allowing synchronized operation when starting out of reset. it is possible to determine whether a rese t was caused by an internal source or an external source. an internal source driv es the pin low for 16 cycles; eight cycles later, the pin is sampled. if the pin has returned high, either the cop watchdog vector or clock monitor vector is taken. if the pin is still low, the external reset is determined to be active and the reset vector is taken. hold reset low for at least 32 cycles to assure that the reset vector is taken in the event that an internal cop watchdog timeout or clock monitor fail occurs. 1.6.3.4 irq irq is the maskable external interrupt requ est pin. it provides a means of applying asynchronous interrupt requests to the mcu. either falling edge-sensitive triggering or level-sensitive triggering is program selectable (interrupt control register, intcr). irq is always configured to level-sensitive triggering at reset. when the mcu is reset, the irq function is masked in the condition code register. this pin is always an input and can always be read. in special modes, it can be used to apply external eeprom v pp in support of eeprom testing. external v pp is not needed for normal eeprom program and erase cycles. because the irq pin is also used as an eeprom programmi ng voltage pin, there is an internal resistive pullup on the pin.
general description data sheet m68hc12b family ? rev. 9.0 30 general description motorola 1.6.3.5 xirq xirq is the non-maskable external interrupt pin. it provides a means of requesting a non-maskable interrupt after reset initialization. during reset, the x bit in the condition code register (ccr) is set a nd any interrupt is masked until mcu software enables it. because the xirq input is level sensitive, it can be connected to a multiple-source wired-or network. this pin is always an input and can always be read. there is an active pullup on this pin while in reset and immediately out of reset. the pullup can be turned off by cl earing the pupe bit in the pullup control register (pucr). xirq is often used as a power loss detect interrupt. when xirq or irq are used with multiple interrupt sources (irq must be configured for level-sensitive operation if there is more than one source of irq interrupt), each source must drive the interrupt input with an open-drain type of driver to avoid contention between outputs. there must also be an interlock mechanism at each interrupt source so that the source holds the interrupt line low until the mcu recognizes and acknowledges the interrupt request. if the interrupt line is held low, the mcu recognizes another interrupt as soon as the interrupt mask bit in the mcu is cleared, normally upon return from an interrupt. 1.6.3.6 smodn, moda, and modb smodn, moda, and modb are the mode-sel ect signals. their state during reset determines the mcu operating mode. after reset, moda and modb can be configured as instruction queue tracking signals ipipe0 and ipipe1. moda and modb have active pulldowns during reset. the smodn pin can be used as bkgd or taghi after reset. note: to aid in mode selection, refer to figure 1-8 and figure 1-9 . these schematics are provided as suggestive layouts only. 1.6.3.7 bkgd bkgd is the single-wire background mode pi n. it receives and transmits serial background debugging commands. a special self-timing protocol is used. the bkgd pin has an active pullup when conf igured as input; bkgd has no pullup control. currently, the tool co nnection configuration shown in figure 1-7 is used. figure 1-7. bdm tool connector 2 4 6 5 3 1 reset bkgd v dd gnd v fp nc
general description pinout and signal descriptions m68hc12b family ? rev. 9.0 data sheet motorola general description 31 1.6.3.8 addr15?addr0 and data15?data0 addr15?addr0 and data15?data0 are the external address and data bus pins. they share functions with general-pur pose i/o ports a and b. in single-chip operating modes, the pins can be used for i/o; in expanded modes, the pins are used for the external buses. in expanded wide mode, ports a and b multiplex 16-bit data and address buses. the pa7?pa0 pins multiplex addr 15?addr8 and data15?data8. the pb7?pb0 pins multiplex addr7?addr0 and data7?data0. in expanded narrow mode, ports a and b are used for the 16-bit address bus. an 8-bit data bus is multiplexed with the mo st significant half of the address bus on port a. in this mode, 16-bit data is handl ed as two back-to-back bus cycles, one for the high byte followed by one for the low byte. the pa7?pa0 pins multiplex addr15?addr8, data15?data8, and data7?data0. the state of the address pin should be latched at the rising edge of e. to allow for maximum address setup time at external device s, a transparent latch should be used. 1.6.3.9 r/w r/w is the read/write pin. in all modes, th is pin can be used as input/output (i/o) and is a general-purpose input with an active pullup out of reset. if the read/write function is required, it should be enabled by setting the rdwe bit in the port e assignment register (pear). external writes are not possible until enabled. 1.6.3.10 lstrb lstrb is the low-byte strobe pin. in all m odes, this pin can be used as i/o and is a general-purpose input with an active pullu p out of reset. if the strobe function is required, it should be enabled by setting the lstre bit in the pear register. this signal is used in write operations and so external low-byte writes are not possible until this function is enabled. this pin is also used as taglo in special expanded modes and is multiplexed with the lstrb function. 1.6.3.11 ipipe1 and ipipe0 ipipe1 and ipipe0 are the instruction queue tracking pins. their signals are used to track the state of the internal instruction execution queue. execution state is time-multiplexed on the two signals. 1.6.3.12 dbe dbe is the data bus enable signal. it is an active-low signal that is asserted low during e-clock high time. dbe provides separation between output of a multiplexed address and the input of data. when an external address is stretched, dbe is asserted during what would be the last quar ter cycle of the last e-clock cycle of stretch. in expanded modes, this pin is used to enable the drive control of external buses during external reads only. use of the dbe is controlled by the ndbe bit in the pear register. dbe is enabled out of reset in expanded modes. this pin has an active pullup during and afte r reset in single-chip modes.
general description data sheet m68hc12b family ? rev. 9.0 32 general description motorola table 1-3. signal description summary pin name pin number description pw3?pw0 3?6 pulse-width modulator channel outputs addr7?addr0 data7?data0 25?18 external bus pins share function with general -purpose i/o ports a and b. in single-chip modes, the pins can be used for i/o. in expanded modes, the pins are used for the external buses. addr15?addr8 data15?data8 46?39 ioc7?ioc0 16?12, 9?7 pins used for input capture and output compare in the timer and pulse accumulator subsystem pai 16 pulse accumulator input an7?an0 58?51 analog inputs for the analog-to-digital conversion module dbe 26 data bus control and, in expanded mode, enables the drive control of external buses during external reads modb, moda 27, 28 state of mode select pins during re set determines the initial operating mode of the mcu. after reset, modb and moda can be configured as instruction queue tracking signals ipipe1 and ipipe0 or as general-purpose i/o pins. ipipe1, ipipe0 27, 28 eclk 29 e-clock is the output connection for the external bus clock. eclk is used as a timing reference and for address demultiplexing. reset 32 an active low bidirecti onal control signal, reset acts as an input to initialize the mcu to a known startup state and an output w hen cop or clock monitor causes a reset. extal 33 crystal driver and external clock input pins. on reset all the device clocks are derived from the extal input frequency. xtal is the crystal output. xtal 34 lstrb 35 low byte strobe (0 = low byte valid), in all modes this pin can be used as i/o. the low strobe function is the exclusive-no r of a0 and the internal sz8 signal. the sz8 internal signal indicates the size 16/8 access. tag l o 35 pin used in instruction tagging r/w 36 indicates direction of data on expansion bus; shares function with general-purpose i/o; read/write in expanded modes irq 37 maskable interrupt request input provides a means of applying asynchronous interrupt requests to the mcu. either falling edge- sensitive triggering or level-sensitive triggering is program selectable (intcr register). xirq 38 provides a means of requesting asynchronous non-maskable interrupt requests after reset initialization bkgd 17 single-wire background interface pin is dedicated to the background debug function. during reset, this pin determines special or normal operating mode. taghi 17 pin used in instruction tagging dlcrx/rxcan (1) 76 bdlc receive pin dlctx/txcan (1) 75 bdlc transmit pin cs /ss 68 slave-select output for spi master mode ; input for slave mode or master mode sck 67 serial clock for spi system sdo/mosi 66 master out/slave in pin for serial peripheral interface sdi/miso 65 master in/slave out pin for serial peripheral interface txd0 62 sci transmit pin rxd0 61 sci receive pin 1. the rxcan and txca n designations are for the mc68hc(9)12bc32 only.
general description pinout and signal descriptions m68hc12b family ? rev. 9.0 data sheet motorola general description 33 1.6.4 port signals the mcu incorporates eight ports which ar e used to control and access the various device subsystems. when not used for these purposes, port pins may be used for general-purpose i/o. in addition to the pins described here, each port consists of:  a data register which can be read and written at any time  with the exception of port ad and pe1?pe0, a data direction register which controls the direction of each pin after reset, all port pins are configured as input. (refer to table 1-4 for a summary of the port signal descriptions.) table 1-4. port description summary port name pin numbers data direction dd register (address) description port a pa 7 ? pa 0 46?39 in/out ddra ($0002) port a and port b pins are used for address and data in expanded modes. the port data registers are not in the address map during expanded and peripheral mode operation. when in the map, port a and port b can be read or written anytime. ddra and ddrb are not in the address map in expanded or peripheral modes. port b pb7?pb0 25?18 in/out ddrb ($0003) port ad pa d 7 ? pa d 0 58?51 in analog-to-digital converter and general-purpose i/o port dlc/pcan (1) pdlc6?pdlc0 pcan6?pcan2 70?76 in/out ddrdlc ($00ff) byte data link communica tion (bdlc) subsystem and general-purpose i/o port e pe7?pe0 26?29, 35?38 pe1?pe0 in pe7?pe2 in/out ddre ($0009) mode selection, bus control signals, and interrupt service request signals; or general-purpose i/o port p pp7?pp0 79, 80, 1?6 in/out ddrp ($0057) general-purpose i/o. pp3?pp0 are used with the pulse-width modulator when enabled. port s ps7?ps0 68?61 in/out ddrs ($00d7) serial communications interface and serial peripheral interface subsystems and general-purpose i/o port t pt7?pt0 16?12, 9?7 in/out ddrt ($00af) general-purpose i/o when not enabled for input capture and output compare in the timer and pulse accumulator subsystem 1. port dlc applies to the mc68hc912b32 and mc68hc12be32 and pcan to the mc68hc(9)12bc32.
general description data sheet m68hc12b family ? rev. 9.0 34 general description motorola 1.6.4.1 port a port a pins are used for address and data in expanded modes. the port data register is not in the address map during expanded and peripheral mode operation. when it is in the map, port a can be read or written at anytime. the port a data direction register (ddra) determines whether each port a pin is an input or output. ddra is not in the address map during expanded and peripheral mode operation. setting a bit in ddra makes the corresponding bit in port a an output; clearing a bit in ddra makes the corresponding bit in port a an input. the default reset state of ddra is all 0s. when the pupa bit in the pucr register is set, all port a input pins are pulled up internally by an active pullup device. this bit has no effect if the port is being used in expanded modes as the pullups are inactive. setting the rdpa bit in the reduced driv e register (rdriv) causes all port a outputs to have reduced drive levels. rdriv can be written once after reset and is not in the address map in peripheral mode. refer to section 6. bus control and input/output (i/o) . 1.6.4.2 port b port b pins are used for address and data in expanded modes. the port data register is not in the address map during expanded and peripheral mode operation. when it is in the map, port b can be read or written at anytime. the port b data direction register (ddrb) determines whether each port b pin is an input or output. ddrb is not in the address map during expanded and peripheral mode operation. setting a bit in ddrb makes the corresponding bit in port b an output; clearing a bit in ddrb makes the corresponding bit in port b an input. the default reset state of ddrb is all 0s. when the pupb bit in the pucr register is set, all port b input pins are pulled up internally by an active pullup device. this bit has no effect if the port is being used in expanded modes because the pullups are inactive. setting the rdpb bit in register rdriv c auses all port b outputs to have reduced drive levels. rdriv can be written once after reset. rdriv is not in the address map in peripheral mode. refer to section 6. bus control and input/output (i/o) . 1.6.4.3 port e port e pins operate differently from port a and b pins. port e pins are used for bus control signals and interrupt service reques t signals. when a pin is not used for one of these specific functions, it can be us ed as general-purpose i/o. however, two of the pins, pe1 and pe0, can be used only for input, and the states of these pins can be read in the port data register even when they are used for irq and xirq .
general description pinout and signal descriptions m68hc12b family ? rev. 9.0 data sheet motorola general description 35 the pear register determines pin function, and the data direction register (ddre) determines whether each pin is an input or output when it is used for general-purpose i/o. pear settings ove rride ddre settings. because pe1 and pe0 are input-only pins, only ddre7? ddre2 have effect. setting a bit in the ddre register makes the corresponding bit in port e an output; clearing a bit in the ddre register makes the corresponding bi t in port e an input. the default reset state of ddre is all 0s. when the pupe bit in the pucr register is set, pe7, pe3, pe2, and pe0 are pulled up. pe7, pe3, pe2, and pe0 are active pul led-up devices, while pe1 is always pulled up by means of an internal resistor. port e and ddre are not in the map in peripheral mode or in expanded modes when the eme bit in the mode register is set. setting the rdpe bit in register rdriv c auses all port e outputs to have reduced drive level. rdriv can be written once after reset. rdriv is not in the address map in peripheral mode. refer to section 6. bus control and input/output (i/o) . 1.6.4.4 port dlc the mc68hc912b32 and mc68hc12be32 contain the port dlc. byte data link communications (bdlc) pi ns can be configured as general-purpose i/o port dlc. when bdlc functions are not enabled, the port has seven general-purpose i/o pins, pdlc6?pdlc0. the port dlc control register (dlcscr) controls port dlc function. the bdlc function, enabled with the bdlcen bit, takes precedence over other port functions. the port dlc data direction register ( ddrdlc) determines whether each port dlc pin is an input or output. setting a bit in ddrdlc makes the corresponding pin in port dlc an output; clearing a bit makes the corresponding pin an input. after reset, port dlc pins are configured as inputs. when the pupdlc bit in the dlcscr register is set, all port dlc input pins are pulled up internally by an active pullup device. setting the rdpdlc bit in register dlcscr causes all port dlc outputs to have reduced drive level. levels are at normal drive capability after reset. rdpdlc can be written anytime after reset. refer to section 15. byte data link communications (bdlc) . 1.6.4.5 port can the mc68hc(9)12bc32 contains the port can. the port can has five general-purpos e i/o pins, pcan[6:2]. the mscan12 receive pin, rxcan, and transmit pin, txcan, cannot be configured as general-purpose i/o on port can.
general description data sheet m68hc12b family ? rev. 9.0 36 general description motorola the mscan data direction register (ddrca n) determines whether each port can pin pcan[6:2] is an input or outpu t. setting a bit in ddrcan makes the corresponding pin in port can an output; clearing a bit makes the corresponding pin an input. after reset, port can pins pcan[6:2] are configured as inputs. when a read to the port can is performed, the value read from the most significant bit (msb) depends on the msb, pcan7, of the port can data register, portcan, and the msb of ddrcan: it is 0 if d drcan7 = 0 and is pcan7 if ddrcan7 = 1. when the peucan bit in the port can control register (pctlcan) is set, port can input pins pcan[6:2] are pulled up inte rnally by an ac tive pullup device. setting the rdrcan bit in register pctlcan causes the port can outputs pcan[6:2} to have reduced drive level. levels are at normal drive capability after reset. rdrcan can be written anytime after reset. refer to section 16. mscan12 controller . 1.6.4.6 port ad port ad provides input to the analog-to-digital subsystem and general-purpose input. when analog-to-digital functions are not enabled, the port has eight general-purpose input pins, pad7?pad0. the adpu bit in the atd control register 2 (atdctl2) enables the a/d function. port ad pins are inputs; no data direction register is associated with this port. the port has no resistive input loads and no reduced drive controls. refer to section 17. analog-to-digital converter (atd) . 1.6.4.7 port p the four pulse-width modulation channel outputs share general-purpose port p pins. the pwm function is enabled with the pwm enable register (pwen). enabling pwm pins takes precedence over the general-purpose port. when pulse-width modulation is not in use, the port pins may be used for general-purpose i/o. the port p data direction register (ddrp) determines pin direction of port p when used for general-purpose i/o. when ddrp bi ts are set, the corresponding pin is configured for output. on reset, the ddrp bits are cleared and the corresponding pin is configured for input. when the pupp bit in the pwm control regist er (pwctl) register is set, all input pins are pulled up internally by an active pullup device. pullups are disabled after reset. setting the rdpp bit in the pwctl register configures all port p outputs to have reduced drive levels. levels are at normal drive capability after reset. the pwctl register can be read or written anytime after reset. refer to section 11. pulse-width modulator (pwm) .
general description pinout and signal descriptions m68hc12b family ? rev. 9.0 data sheet motorola general description 37 1.6.4.8 port t this port provides eight general-purpos e i/o pins when not enabled for input capture and output compare in the timer and pulse accumulator subsystem. the ten bit in the timer system control register (tscr) enables the timer function. the pulse accumulator subsystem is enabled with the paen bit in the pulse accumulator control register (pactl). the port t data direction register (ddrt) determines pin direction of port t when used for general-purpose i/o. when ddrt bi ts are set, the corresponding pin is configured for output. on reset the ddrt bits are cleared and the corresponding pin is configured for input. when the pupt bit in the timer mask regist er 2 (tmsk2) is set, all input pins are pulled up internally by an active pullup device. pullups are disabled after reset. setting the rdpt bit in the tmsk2 register configures all port t outputs to have reduced drive levels. levels are at normal drive capability after reset. the tmsk2 register can be read or written anytime after reset. for the mc68hc912b32 and mc68hc(9)12bc32, refer to section 12. standard timer module (tim) . for the mc68hc12be32, refer to section 13. enhanced capture timer (ect) module . 1.6.4.9 port s port s is the 8-bit interface to the standard serial interface consisting of the serial communications interface (sci) and serial peripheral interface (spi) subsystems. port s pins are available for general -purpose parallel i/o when standard serial functions are not enabled. port s pins serve several functions de pending on the various internal control registers. if woms bit in the sci control register 1 (sc0cr1) is set, the p-channel drivers of the output buffers are disabled for bits 0?1 (2?3). if swom bit in the sp0cr1 register is set, the p-channel drivers of the output buffers are disabled for bits 4?7 (wired-or mode). the open drain control affects both the serial and the general-purpose outputs. if the rdpsx bits in the purds register are set, the appropriate port s pin drive capabilities are reduced. if pupsx bits in the port s pullup, reduced drive register (purds) are set, the appropriate pullup device is connected to each port s pin which is pr ogrammed as a general-purpose input. if the pin is programmed as a general-purpose output, the pullup is disconnected from the pin regardless of the st ate of the individual pupsx bits. 1.6.5 port pullup, pulldown, and reduced drive mcu ports can be configured for internal pullup. to reduce power consumption and rfi, the pin output drivers can be configured to operate at a reduced drive level. reduced drive causes a slight increase in transition time depending on loading and should be used only for ports which have a light loading. table 1-5 summarizes the port pullup default status and controls.
general description data sheet m68hc12b family ? rev. 9.0 38 general description motorola table 1-5. port pullup, pulldown, and reduced drive summary port name resistive input loads enable bit reduced drive control bit register (address) bit name reset state register (address) bit name reset state port a pullup pucr ($000c) pupa disabled rdriv ($000d) rdpa full drive port b pullup pucr ($000c) pupb disabled rdriv ($000d) rdpb full drive port e pe7, pe3, pe2, pe1, pe0 pullup pucr ($000c) pupe enabled rdriv ($000d) rdpe full drive port e pe4 none ? rdriv ($000d) rdpe full drive port e pe6, pe5 pulldown enabled during reset ? ? ? port p pullup pwctl ($0054) pupp disabled pwctl ($0054) rdpp full drive port s ps1?ps0 pullup purds ($00db) pups0 disabled purds ($00db) rdps0 full drive port s ps3?ps2 pullup purds ($00db) pups1 disabled purds ($00db) rdps1 full drive port s ps7?ps4 pullup purds ($00db) pups2 disabled purds ($00db) rdps2 full drive port t pullup tmsk2 ($008d) pupt disabled tmsk2 ($008d) rdpt full drive port dlc/pcan (1) pullup dlcscr ($00fd) dlcpue disabled dlcscr ($00fd) dlcrdv full drive port ad none ? ? bkgd pullup ? ? enabled ? ? full drive 1. port dlc applies to the mc68hc912b32 and mc68hc12be32 and pcan to the mc68hc(9)12bc32.
m68hc12b family ? rev. 9.0 data sheet motorola general description 39 general description pinout and signal descriptions figure 1-8. basic single-chip mode schematic 10 47 78 31 59 11 48 77 30 49 50 69 33 34 32 17 38 37 36 35 29 28 27 26 v dd0 v dd1 v ddx0 v ddx1 v ddad v ss0 v ss1 v ssx0 v ssx1 18 19 20 21 22 23 24 25 pb0 pb1 pb2 pb3 pb4 pb5 pb6 pb7 39 40 41 42 43 44 45 46 pa0 pa1 pa2 pa3 pa4 pa5 pa6 pa7 61 62 63 64 65 66 67 68 ps0 ps1 ps2 ps3 ps4 ps5 ps6 ps7 51 52 53 54 55 56 57 58 pad0 pad1 pad2 pad3 pad4 pad5 pad6 pad7 7 8 9 12 13 14 15 16 pt0 pt1 pt2 pt3 pt4 pt5 pt6 pt7 6 5 4 3 2 1 80 79 76 75 74 73 72 71 pp0 pp1 pp2 pp3 pp4 pp5 pp6 pp7 v rh v rl v fp extal xtal reset bkgd pe0 pe1 pe2/r/w pe3/lstrb pe4/eclock pe5/moda pe6/modb pe7/dbe pdlc0 pdlc1 pdlc2 pdlc3 pdlc4 pdlc5 v dd0 v dd1 v ddx1 v ddx0 v ddad c2 c1 y1 jp1 1 2 3 4 5 6 gnd v dd 1 2 3 4 5 6 mc68hc912b32 header 6 u1 reset moda modb r29 r31 r34 r36 r38 r40 r42 r44 r46 r48 r50 r52 r54 r56 r57 r58 v ddex0 4 3 moda modb sw dip-2 1 2 s1 v dd v dd r2 4.7 k r3 4.7 k r14 r32 4.7 k v dd1 c6 1.0 f c5 1.0 f c4 1.0 f v ddex0 v ddad c3 1.0 f v dd0 ground v fp dn in rset 21 3 u2 mc34064 reset v fp 70 pdlc6 v dd note: this figure provides a suggested schematic only.
data sheet m68hc12b family ? rev. 9.0 40 general description motorola general description figure 1-9. ram expansion schematic with flash in narrow mode 6 e clock a15 10 47 78 31 59 11 48 77 30 49 50 69 33 34 32 17 38 37 36 35 29 28 27 26 v dd0 v dd1 v ddx0 v ddx1 v ddad v ss0 v ss1 v ssx0 v ssx1 18 19 20 21 22 23 24 25 pb0 pb1 pb2 pb3 pb4 pb5 pb6 pb7 39 40 41 42 43 44 45 46 pa0 pa1 pa2 pa3 pa4 pa5 pa6 pa7 61 62 63 64 65 66 67 68 ps0 ps1 ps2 ps3 ps4 ps5 ps6 ps7 51 52 53 54 55 56 57 58 pad0 pad1 pad2 pad3 pad4 pad5 pad6 pad7 7 8 9 12 13 14 15 16 pt0 pt1 pt2 pt3 pt4 pt5 pt6 pt7 6 5 4 3 2 1 80 79 76 75 74 73 72 71 pp0 pp1 pp2 pp3 pp4 pp5 pp6 pp7 v rh v rl v fp extal xtal reset bkgd pe0 pe1 pe2/r/w pe3/lstrb pe4/eclock pe5/moda pe6/modb pe7/dbe pdlc0 pdlc1 pdlc2 pdlc3 pdlc4 pdlc5 dn in rset 21 3 u1 mc34064 reset v dd v dd v ddx1 v ddx0 v dd ground r1 c2 c1 y1 jp1 1 2 3 4 5 6 gnd v dd 1 2 3 4 5 6 e clock mc68hc912b32 header 6 d0 d1 d2 d3 d4 d5 d7 3 4 7 8 13 14 17 18 d6 d0 d1 d2 d3 d4 d5 d6 d7 u3 oc clk 74hc374 1 11 e clock q0 q1 q2 q3 q4 q5 q6 q7 2 5 6 9 12 15 16 19 a15 a14 a13 a12 a11 a10 a9 a8 a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 10 9 8 7 6 5 4 3 25 24 21 23 2 26 1 a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 11 12 13 14 15 16 17 18 d0 d1 d2 d3 d4 d5 d6 d7 d0 d1 d2 d3 d4 d5 d6 d7 ce r/w oe ram ic 20 27 22 u4 u2 reset v fp moda modb r/w 1 2 3 4 5 a b c g1 g2a g2b u6 74ahct138 y0 y1 y2 y3 y4 y5 y6 y7 15 14 13 12 11 10 9 7 ram flash a13 a14 a15 ram r/w a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 12 11 10 9 8 7 6 5 27 26 23 25 4 28 29 a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 13 14 15 17 18 19 20 21 d0 d1 d2 d3 d4 d5 d6 d7 d0 d1 d2 d3 d4 d5 d6 d7 ce oe 22 24 31 u4 flash ground a15 a16 3 2 1 pgm v pp flash v dd am27c010 r62 10 k v dd1 c10 0.1 f c9 0.1 f c8 0.1 f v ddx0 v ddx1 v fp 70 pdlc6 d0 d1 d2 d3 d4 d5 d7 d6 4 3 moda modb sw dip-2 1 2 s1 v dd v dd r2 4.7 k r3 4.7 k r32 4.7 k note: this figure provides a suggested schematic only.
m68hc12b family ? rev. 9.0 data sheet motorola register block 41 data sheet ? m68hc12b family section 2. register block 2.1 introduction the register block can be mapped to any 2-kbyte boundary within the standard 64-kbyte address space by manipulati ng bits reg15?reg11 in the register initialization register (initrg). initrg establishes the upper five bits of the register block?s 16-bit address. the regist er block occupies the first 512 bytes of the 2-kbyte block. default addressing (after reset) is indicated in figure 2-1 . for additional information, refer to section 5. operating modes and resource mapping . note: in expanded and peripheral modes, these registers are not in the map:  port a data register, porta  port b data register, portb  port a data direction register, ddra  port b data direction register, ddrb in peripheral mode or in expanded modes with the emulate port e bit (eme) set, these registers are not in the map:  port e data register, porte  port e data direction register, ddre in peripheral mode, these registers are not in the map:  mode register, mode  pullup control register, pucr  reduced drive register, rdriv
register block data sheet m68hc12b family ? rev. 9.0 42 register block motorola 2.2 registers addr. register name bit 7654321bit 0 $0000 port a data register (porta) see page 88. read: pa7 pa6 pa5 pa4 pa3 pa2 pa1 pa0 write: reset:uuuuuuuu $0001 port b data register (portb) see page 89. read: pb7 pb6 pb5 pb4 pb3 pb2 pb1 pb0 write: reset:uuuuuuuu $0002 data direction register a (ddra) see page 89. read: dda7 dda6 dda5 dda4 dda3 dda2 dda1 dda0 write: reset:00000000 $0003 data direction register b (ddrb) see page 90. read: ddb7 ddb6 ddb5 ddb4 ddb3 ddb2 ddb1 ddb0 write: reset:00000000 $0004 reserved r r r r r r r r $0007 reserved r r r r r r r r $0008 port e data register (porte) see page 90. read: pe7 pe6 pe5 pd4 pd3 pd2 pd1 pd0 write: reset:00000000 $0009 data direction register e (ddre) see page 91. read: dde7 dde6 dde5 dde4 dde3 dde2 00 write: reset:00001000 $000a port e assignment register (pear) see page 92. read: ndbe cgmte pipoe neclk lstre rdwe 00 write: reset:10010000 $000b mode register (mode) see page 81. read: smodn modb moda estr ivis ebswai 0 eme write: reset:00011001 $000c pullup control register (pucr) see page 94. read: 0 0 0 pupe 00 pupb pupa write: reset:00010000 $000d reduced drive register (rdriv) see page 95. read:0000 rdpe 0 rdpb rdpa write: reset:00000000 $000e reserved r r r r r r r r = unimplemented r = reserved u = unaffected notes: 1. available only on mc68hc912b32 and mc68hc912bc32 devices. 2. available only on mc68hc912b32 and mc68hc12be32 devices. 3. available only on mc68hc(9)12bc32 devices. figure 2-1. register map (sheet 1 of 19)
register block registers m68hc12b family ? rev. 9.0 data sheet motorola register block 43 $000f reserved r r r r r r r r $0010 ram initialization register (initrm) see page 83. read: ram15ram14ram13ram12ram11 0 0 0 write: reset:00001000 $0011 register initialization register (initrg) see page 82. read: reg15 reg14 reg13 reg12 reg11 0 0 mmswai write: reset:00000000 $0012 eeprom initialization register (initee) see page 83. read: ee15 ee14 ee13 ee12 0 0 0 eeon write: reset:00010001 $0013 miscellaneous mapping control register (misc) see page 84. read: 0 ndrf rfstr1 rfstr0 exstr1 exstr0 maprom romon write: reset:00000000 $0014 real-time interrupt control register (rtictl) see page 124. read: rtie rswai rsbck 0 rtbyp rtr2 rtr1 rtr0 write: reset:00000000 $0015 real-time interrupt flag register (rtiflg) see page 125. read: rtif0000000 write: reset:00000000 $0016 cop control register (copctl) see page 125. read: cme fcme fcm fcop disr cr2 cr1 cr0 write: reset:00000001 $0017 arm/reset cop timer register (coprst) see page 127. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $0018 reserved r r r r r r r r $001d reserved r r r r r r r r $001e interrupt control register (intcr) see page 72. read: irqeirqendly00000 write: reset:01100000 $001f highest priority i interrupt register (hprio) see page 73. read: 1 1 psel5 psel4 psel3 psel2 psel1 0 write: reset:11110010 addr. register name bit 7654321bit 0 = unimplemented r = reserved u = unaffected notes: 1. available only on mc68hc912b32 and mc68hc912bc32 devices. 2. available only on mc68hc912b32 and mc68hc12be32 devices. 3. available only on mc68hc(9)12bc32 devices. figure 2-1. register map (sheet 2 of 19)
register block data sheet m68hc12b family ? rev. 9.0 44 register block motorola $0020 breakpoint control register 0 (brkct0) see page 329. read: bken1 bken0 bkpm 0 bk1ale bk0ale 0 0 write: reset:00000000 $0021 breakpoint control register 1 (brkct1) see page 330. read: 0 bkdbe bkmbh bkmbl bk1rwe bk1rw bk0rwe bk0rw write: reset:00000000 $0022 breakpoint address register high (brkah) see page 332. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 $0023 breakpoint address register low (brkal) see page 332. read: bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 write: reset:00000000 $0024 breakpoint data register high (brkdh) see page 332. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 $0025 breakpoint data register low (brkdl) see page 333. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $0026 reserved r r r r r r r r $003f reserved r r r r r r r r $0040 pwm clocks and concatenate register (pwclk) see page 135. read: con23 con01 pcka2 pcka1 pcka0 pckb2 pckb1 pckb0 write: reset:00000000 $0041 pwm clock select and polarity register (pwpol) see page 136. read: pclk3 pclk2 pclk1 pclk0 ppol3 ppol2 ppol1 ppol0 write: reset:00000000 $0042 pwm enable register (pwen) see page 138. read:0000 pwen3 pwen2 pwen1 pwen0 write: reset:00000000 $0043 pwm prescaler counter register (pwpres) see page 139. read: 0 bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $0044 pwm scale register 0 (pwscal0) see page 139. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 addr. register name bit 7654321bit 0 = unimplemented r = reserved u = unaffected notes: 1. available only on mc68hc912b32 and mc68hc912bc32 devices. 2. available only on mc68hc912b32 and mc68hc12be32 devices. 3. available only on mc68hc(9)12bc32 devices. figure 2-1. register map (sheet 3 of 19)
register block registers m68hc12b family ? rev. 9.0 data sheet motorola register block 45 $0045 pwm scale counter register 0 (pwscnt0) see page 139. read:bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $0046 pwm scale register 1 (pwscal1) see page 140. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $0047 pwm scale counter register 1 (pwscnt1) see page 140. read:bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $0048 pwm channel counter register 0 (pwcnt0) see page 141. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $0049 pwm channel counter register 1 (pwcnt1) see page 141. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $004a pwm channel counter register 2 (pwcnt2) see page 141. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $004b pwm channel counter register 3 (pwcnt3) see page 141. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $004c pwm channel period register 0 (pwper0) see page 142. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:11111111 $004d pwm channel period register 1 (pwper1) see page 142. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:11111111 $004e pwm channel period register 2 (pwper2) see page 142. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:11111111 $004f pwm channel period register 3 (pwper3) see page 142. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:11111111 $0050 pwm channel duty register 0 (pwdty0) see page 143. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:11111111 addr. register name bit 7654321bit 0 = unimplemented r = reserved u = unaffected notes: 1. available only on mc68hc912b32 and mc68hc912bc32 devices. 2. available only on mc68hc912b32 and mc68hc12be32 devices. 3. available only on mc68hc(9)12bc32 devices. figure 2-1. register map (sheet 4 of 19)
register block data sheet m68hc12b family ? rev. 9.0 46 register block motorola $0051 pwm channel duty register 1 (pwdty1) see page 143. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:11111111 $0052 pwm channel duty register 2 (pwdty2) see page 143. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:11111111 $0053 pwm channel duty register 3 (pwdty3) see page 143. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:11111111 $0054 pwm control register (pwctl) see page 144. read: 0 0 0 pswai centr rdpp pupp psbck write: reset:00000000 $0055 pwm special mode register (pwtst) see page 145. read: discr discp discal 00000 write: reset:00000000 $0056 port p data register (portp) see page 145. read: pp7 pp6 pp5 pp4 pp3 pp2 pp1 pp0 write: reset:uuuuuuuu $0057 port p data direction register (ddrp) see page 146. read: ddp7 ddp6 ddp5 ddp4 ddp3 ddp2 ddp1 ddp0 write: reset:00000000 $0058 reserved r r r r r r r r $005f reserved r r r r r r r r $0060 atd control register 0 (atdctl0) see page 303. read: 00000000 write: reset:00000000 $0061 atd control register 1 (atdctl1) see page 303. read: 00000000 write: reset:00000000 $0062 atd control register 2 (atdctl2) see page 303. read: adpu affc awai 000 ascie ascif write: reset:00000000 $0063 atd control register 3 (atdctl3) see page 304. read:000000 frz1 frz0 write: reset:00000000 addr. register name bit 7654321bit 0 = unimplemented r = reserved u = unaffected notes: 1. available only on mc68hc912b32 and mc68hc912bc32 devices. 2. available only on mc68hc912b32 and mc68hc12be32 devices. 3. available only on mc68hc(9)12bc32 devices. figure 2-1. register map (sheet 5 of 19)
register block registers m68hc12b family ? rev. 9.0 data sheet motorola register block 47 $0064 atd control register 4 (atdctl4) see page 305. read: s10bmsmp1smp0prs4prs3prs2prs1prs0 write: reset:00000001 $0065 atd control register 5 (atdctl5) see page 307. read: s8cm scan mult cd cc cb ca write: reset:00000000 $0066 atd status register (atdstat) see page 309. read: scf 0 0 0 0 cc2 cc1 cc0 write: reset:00000000 $0067 atd status register (atdstat) see page 309. read: ccf7 ccf6 ccf5 ccf4 ccf3 ccf2 ccf1 ccf0 write: reset:00000000 $0068 atd test register high (atdtsth) see page 310. read: sar9 sar8 sar7 sar6 sar5 sar4 sar3 sar2 write: reset:00000000 $0069 atd test register low (atdtstl) see page 310. read: sar1 sar0 rst tstout tst3 tst2 tst1 tst0 write: reset:00000000 $006a reserved r r r r r r r r $006e reserved r r r r r r r r $006f port ad data input register (portad) see page 311. read: pad7 pad6 pad5 pad4 pad3 pad2 pad1 pad0 write: reset: after reset, reflect the state of the input pins $0070 atd result register 0 (adrx0h) see page 311. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset: undefined $0071 atd result register 0 (adrx0l) see page 312. read:bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset: undefined $0072 atd result register 1 (adrx1h) see page 312. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset: undefined $0073 atd result register 1 (adrx1l) see page 312. read:bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset: undefined addr. register name bit 7654321bit 0 = unimplemented r = reserved u = unaffected notes: 1. available only on mc68hc912b32 and mc68hc912bc32 devices. 2. available only on mc68hc912b32 and mc68hc12be32 devices. 3. available only on mc68hc(9)12bc32 devices. figure 2-1. register map (sheet 6 of 19)
register block data sheet m68hc12b family ? rev. 9.0 48 register block motorola $0074 atd result register 2 (adrx2h) see page 312. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset: undefined $0075 atd result register 2 (adrx2l) see page 312. read:bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset: undefined $0076 atd result register 3 (adrx3h) see page 312. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset: undefined $0077 atd result register 3 (adrx3l) see page 312. read:bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset: undefined $0078 atd result register 4 (adrx4h) see page 312. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset: undefined $0079 atd result register 4 (adrx4l) see page 312. read:bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset: undefined $007a atd result register 5 (adrx5h) see page 312. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset: undefined $007b atd result register 5 (adrx5l) see page 312. read:bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset: undefined $007c atd result register 6 (adrx6h) see page 312. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset: undefined $007d atd result register 6 (adrx6l) see page 312. read:bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset: undefined $007e atd result register 7 (adrx7h) see page 312. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset: undefined $007f atd result register 7 (adrx7l) see page 312. read:bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset: undefined addr. register name bit 7654321bit 0 = unimplemented r = reserved u = unaffected notes: 1. available only on mc68hc912b32 and mc68hc912bc32 devices. 2. available only on mc68hc912b32 and mc68hc12be32 devices. 3. available only on mc68hc(9)12bc32 devices. figure 2-1. register map (sheet 7 of 19)
register block registers m68hc12b family ? rev. 9.0 data sheet motorola register block 49 $0080 timer ic/oc select register (tios) see page 151. read: ios7 ios6 ios5 ios4 ios3 ios2 ios1 ios0 write: reset:00000000 $0081 timer compare force register (cforc) see page 151. read: foc7 foc6 foc5 foc4 foc3 foc2 foc1 foc0 write: reset:00000000 $0082 timer output compare 7 mask register (oc7m) see page 152. read: oc7m7oc7m6oc7m5oc7m4oc7m3oc7m2oc7m1oc7m0 write: reset:00000000 $0083 timer output compare 7 data register (oc7d) see page 152. read: oc7d7 oc7d6 oc7d5 oc7d4 oc7d3 oc7d2 oc7d1 oc7d0 write: reset:00000000 $0084 timer count register high (tcnth) see page 153. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 $0085 timer count register low (tcntl) see page 153. read:bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $0086 timer system control register (tscr) see page 153. read: ten tswai tsbck tffca write: reset:00000000 $0087 reserved r r r r r r r r $0088 timer control register 1 (tctl1) see page 154. read: om7 ol7 om6 ol6 om5 ol5 om4 ol4 write: reset:00000000 $0089 timer control register 2 (tctl2) see page 154. read: om3 ol3 om2 ol2 om1 ol1 om0 ol0 write: reset:00000000 $008a timer control register 3 (tctl3) see page 155. read: edg7b edg7a edg6b edg6a edg5b edg5a edg4b edg4a write: reset:00000000 $008b timer control register 4 (tctl4) see page 155. read: edg3b edg3a edg2b edg2a edg1b edg1a edg0b edg0a write: reset:00000000 addr. register name bit 7654321bit 0 = unimplemented r = reserved u = unaffected notes: 1. available only on mc68hc912b32 and mc68hc912bc32 devices. 2. available only on mc68hc912b32 and mc68hc12be32 devices. 3. available only on mc68hc(9)12bc32 devices. figure 2-1. register map (sheet 8 of 19)
register block data sheet m68hc12b family ? rev. 9.0 50 register block motorola $008c timer mask register 1 (tmsk1) see page 156. read: c7i c6i c5i c4i c3i c2i c1i c0i write: reset:00000000 $008d timer mask register 2 (tmsk2) see page 156. read: toi 0 pupt rdpt tcre pr2 pr1 pr0 write: reset:00000000 $008e timer interrupt flag register 1 (tflg1) see page 157. read: c7f c6f c5f c4f c3f c2f c1f c0f write: reset:00000000 $008f timer interrupt flag register 2 (tflg2) see page 158. read: tof0000000 write: reset:00000000 $0090 timer input capture/output compare 0 register high (tc0h) see page 158. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 $0091 timer input capture/output compare 0 register low (tc0l) see page 158. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $0092 timer input capture/output compare 1 register high (tc1h) see page 159. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 $0093 timer input capture/output compare 1 register low (tc1l) see page 159. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $0094 timer input capture/output compare 2 register high (tc2h) see page 159. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 $0095 timer input capture/output compare 2 register low (tc2l) see page 159. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $0096 timer input capture/output compare 3 register high (tc3h) see page 160. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 $0097 timer input capture/output compare 3 register low (tc3l) see page 160. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 addr. register name bit 7654321bit 0 = unimplemented r = reserved u = unaffected notes: 1. available only on mc68hc912b32 and mc68hc912bc32 devices. 2. available only on mc68hc912b32 and mc68hc12be32 devices. 3. available only on mc68hc(9)12bc32 devices. figure 2-1. register map (sheet 9 of 19)
register block registers m68hc12b family ? rev. 9.0 data sheet motorola register block 51 $0098 timer input capture/output compare 4 register high (tc4h) see page 160. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 $0099 timer input capture/output compare 4 register low (tc4l) see page 160. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $009a timer input capture/output compare 5 register high (tc5h) see page 160. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 $009b timer input capture/output compare 5 register low (tc5l) see page 160. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $009c timer input capture/output compare 6 register high (tc6h) see page 160. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 $009d timer input capture/output compare 6 register low (tc6l) see page 160. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $009e timer input capture/output compare 7 register high (tc7h) see page 161. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 $009f timer input capture/output compare 7 register low (tc7l) see page 161. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $00a0 pulse accumulator control register (pactl) see page 161. read: 0 paen pamod pedge clk1 clk0 paovi pai write: reset:00000000 $00a1 pulse accumulator flag register (paflg) see page 163. read: 0 0 0 0 0 0 paovf paif write: reset:00000000 $00a2 pulse accumulator count register 3 (pacn3) see page 190. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $00a3 pulse accumulator count register 2 (pacn2) see page 190. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 addr. register name bit 7654321bit 0 = unimplemented r = reserved u = unaffected notes: 1. available only on mc68hc912b32 and mc68hc912bc32 devices. 2. available only on mc68hc912b32 and mc68hc12be32 devices. 3. available only on mc68hc(9)12bc32 devices. figure 2-1. register map (sheet 10 of 19)
register block data sheet m68hc12b family ? rev. 9.0 52 register block motorola $00a4 pulse accumulator count register 1 (pacn1) see page 190. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $00a5 pulse accumulator count register 0 (pacn0) see page 190. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $00a6 16-bit modulus down-counter control register (mcctl) see page 191. read: mczi modmc rdmcl iclat flmc mcen mcpr1 mcpr0 write: reset:00000000 $00a7 16-bit modulus down-counter flag register (mcflg) see page 192. read: mczf 0 0 0 polf3 polf2 polf1 polf0 write: reset:00000000 $00a8 input control pulse accumulators control register (icpacr) see page 193. read: 0 0 0 0 pa3en pa2en pa1en pa0en write: reset:00000000 $00a9 delay counter control register (dlyct) see page 193. read: 000000dly1dly0 write: reset:00000000 $00aa input control overwrite register (icovw) see page 194. read: novw7 novw6 novw5 novw4 novw3 novw2 novw1 novw0 write: reset:00000000 $00ab input control system control register (icsys) see page 194. read: sh37 sh26 sh15 hs04 tfmod pacmx bufen latq write: reset:00000000 $00ac reserved r r r r r r r r $00ad timer test register (timtst) see page 196. read: 0 0 0 0 0 0 tcbyp pcbyp (1) write: reset:00000000 $00ae timer port data register (portt) see page 196. read: pt7 pt6 pt5 pt4 pt3 pt2 pt1 pt0 write: reset:00000000 $00af data direction register for timer port (ddrt) see page 197. read: ddt7 ddt6 ddt5 ddt4 ddt3 ddt2 ddt1 ddt0 write: reset:00000000 addr. register name bit 7654321bit 0 = unimplemented r = reserved u = unaffected notes: 1. available only on mc68hc912b32 and mc68hc912bc32 devices. 2. available only on mc68hc912b32 and mc68hc12be32 devices. 3. available only on mc68hc(9)12bc32 devices. figure 2-1. register map (sheet 11 of 19)
register block registers m68hc12b family ? rev. 9.0 data sheet motorola register block 53 $00b0 16-bit pulse accumulator b control register (pbctl) see page 197. read: 0 pben 0 0 0 0 pbov 0 write: reset:00000000 $00b1 pulse accumulator b flag register (pbflg) see page 198. read: 000000pbov0 write: reset:00000000 $00b2 8-bit pulse accumulator holding register 3 (pa3h) see page 198. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $00b3 8-bit pulse accumulator holding register 2 (pa2h) see page 198. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $00b4 8-bit pulse accumulator holding register 1 (pa1h) see page 198. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $00b5 8-bit pulse accumulator holding register 0 (pa0h) see page 199. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $00b6 modulus down-counter count register (mccnt) see page 199. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:11111111 $00b7 modulus down-counter count register (mccnt) see page 199. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:11111111 $00b8 timer input capture holding register 0 (tc0h) see page 200. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00100000 $00b9 timer input capture holding register 0 (tc0h) see page 200. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $00ba timer input capture holding register 1 (tc1h) see page 200. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 $00bb timer input capture holding register 1 (tc1h) see page 200. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 addr. register name bit 7654321bit 0 = unimplemented r = reserved u = unaffected notes: 1. available only on mc68hc912b32 and mc68hc912bc32 devices. 2. available only on mc68hc912b32 and mc68hc12be32 devices. 3. available only on mc68hc(9)12bc32 devices. figure 2-1. register map (sheet 12 of 19)
register block data sheet m68hc12b family ? rev. 9.0 54 register block motorola $00bc timer input capture holding register 2 (tc2h) see page 201. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 $00bd timer input capture holding register 2 (tc2h) see page 201. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $00be timer input capture holding register 3 (tc3h) see page 201. read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 $00bf timer input capture holding register 3 (tc3h) see page 201. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $00c0 sci 0 baud rate control register high (sc0bdh) see page 206. read: btst bspl brld sbr12 sbr11 sbr10 sbr9 sbr8 write: reset:00000000 $00c1 sci 0 baud rate control register low (sc0bdl) see page 206. read: sbr7 sbr6 sbr5 sbr4 sbr3 sbr2 sbr1 sbr0 write: reset:00000100 $00c2 sci control register 1 (sc0cr1) see page 207. read: loops woms rsrc m wake ilt pe pt write: reset:00000000 $00c3 sci control register 2 (sc0cr2) see page 209. read: tie tcie rie ilie te re rwu sbk write: reset:00000000 $00c4 sci status register 1 (sc0sr1) see page 210. read: tdre tc rdrf idle or nf fe pf write: reset:11000000 $00c5 sci status register 2 (sc0sr2) see page 212. read:0000000raf write: reset:00000000 $00c6 sci data register high (sc0drh) see page 213. read: r8 t8000000 write: reset:uu000000 $00c7 sci data register low (sc0drl) see page 213. read: r7t7 r6t6 r5t5 r4t4 r3t3 r2t2 r1t1 r0t0 write: reset: unaffected by reset addr. register name bit 7654321bit 0 = unimplemented r = reserved u = unaffected notes: 1. available only on mc68hc912b32 and mc68hc912bc32 devices. 2. available only on mc68hc912b32 and mc68hc12be32 devices. 3. available only on mc68hc(9)12bc32 devices. figure 2-1. register map (sheet 13 of 19)
register block registers m68hc12b family ? rev. 9.0 data sheet motorola register block 55 $00c8 reserved r r r r r r r r $00cf reserved r r r r r r r r $00d0 spi control register 1 (sp0cr1) see page 217. read: spie spe swom mstr cpol cpha ssoe lsbf write: reset:00000000 $00d1 spi control register 2 (sp0cr2) see page 218. read:0000 pups rds 0 spc0 write: reset:00001000 $00d2 spi baud rate register (sp0br) see page 219. read:00000 spr2 spr1 spr0 write: reset:00000000 $00d3 spi status register (sp0sr) see page 220. read: spif wcol 0 modf 0 0 0 0 write: reset:00000000 $00d4 reserved r r r r r r r r $00d5 spi data register (sp0dr) see page 221. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset: unaffected by reset $00d6 port s data register (ports) see page 221. read: ps7 ps6 ps5 ps4 ps3 ps2 ps1 ps0 write: reset: after reset all bits configured as general-purpose inputs $00d7 port s data direction register (ddrs) see page 222. read: dds7 dds6 dds5 dds4 dds3 dds2 dds1 dds0 write: reset: after reset all bits configured as general-purpose inputs $00d8 reserved r r r r r r r r $00da reserved r r r r r r r r $00db port s pullup/reduced drive register (purds) see page 223. read: 0 rdps2 rdps1 rdps0 0 pups2 pups1 pups0 write: reset:00000000 $00dc reserved rrrrrrrr $00df reserved r r r r r r r r addr. register name bit 7654321bit 0 = unimplemented r = reserved u = unaffected notes: 1. available only on mc68hc912b32 and mc68hc912bc32 devices. 2. available only on mc68hc912b32 and mc68hc12be32 devices. 3. available only on mc68hc(9)12bc32 devices. figure 2-1. register map (sheet 14 of 19)
register block data sheet m68hc12b family ? rev. 9.0 56 register block motorola $00e0 slow mode divider register (slow) see page 123. read:00000 sldv2 sldv1 sldv0 write: reset:00000000 $00e1 reserved r r r r r r r r $00ef reserved r r r r r r r r $00f0 eeprom configuration register (eemcr) see page 99. read: 1 1 1 1 1 eeswai protlck eerc write: reset:11111100 $00f1 eeprom block protect register (eeprot) see page 100. read: 1 1 1 brprot4 brprot3 brprot2 brprot1 brprot0 write: reset:11111111 $00f2 eeprom test register (eetst) see page 101. read: eeodd eeven marg eecpd eecprd 0 eecpm 0 write: reset:00000000 $00f3 eeprom control register (eeprog) see page 102. read: bulkp 0 0 byte row erase eelat eepgm write: reset:10000000 $00f4 flash eeprom lock control register (feelck) (1) see page 106. read: 0000000lock write: reset:00000000 $00f5 flash eeprom configuration register (feemcr) (1) see page 106. read: 0000000bootp write: reset:00000001 $00f6 flash eeprom test register (feetst) (1) see page 107. read: fste gadr hvt fenlv fdisvfp vtck stre mwpr write: reset:00000000 $00f7 flash eeprom control register (feectl) (1) see page 108. read: 0 0 0 feeswai svfp eras lat enpe write: reset:00000000 $00f8 bdlc control register 1 (bcr1) (2) see page 249. read: imsg clks r1 r0 00 ie wcm write: r r reset:11100000 $00f9 bdlc state vector register (bsvr) (2) see page 256. read: 0 0 i3 i2 i1 i0 0 0 write: reset:00000000 addr. register name bit 7654321bit 0 = unimplemented r = reserved u = unaffected notes: 1. available only on mc68hc912b32 and mc68hc912bc32 devices. 2. available only on mc68hc912b32 and mc68hc12be32 devices. 3. available only on mc68hc(9)12bc32 devices. figure 2-1. register map (sheet 15 of 19)
register block registers m68hc12b family ? rev. 9.0 data sheet motorola register block 57 $00fa bdlc control register 2 (bcr2) (2) see page 250. read: aloop dloop rx4xe nbfs teod tsifr tmifr1 tmifr0 write: reset:11000000 $00fb bdlc data register (bdr) (2) see page 258. read: bd7 bd6 bd5 bd4 bd3 bd2 bd1 bd0 write: reset: indeterminate after reset $00fc bdlc analog roundtrip delay register (bard) (2) see page 259. read: ate rxpol 00 bo3 bo2 bo1 bo0 write: reset:11000111 $00fd port dlc control register (dlcscr) (2) see page 260. read:00000 bdlcen pupdlc rdpdlc write: reset:00000000 $00fe port dlc data register (portdlc) (2) see page 261. read: 0 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 write: reset:0uuuuuuu $00ff port dlc data direction register (ddrdlc) (2) see page 262. read: 0 dddlc6 dddlc5 dddlc4 dddlc3 dddlc2 dddlc1 dddlc0 write: reset:00000000 $0100 mscan12 module control register 0 (cmcr0) (3) see page 284. read: 0 0 cswai synch tlnken slpak slprq sftres write: reset:00100001 $0101 mscan12 module control register 1 (cmcr1) (3) see page 286. read:00000 loopb wupm clksrc write: reset:00000000 $0102 mscan12 bus timing register 0 (cbtr0) (3) see page 287. read: sjw1 sjw0 brp5 brp4 bpr3 bpr2 bpr1 bpr0 write: reset:00000000 $0103 mscan12 bus timing register 1 (cbtr1) (3) see page 288. read: samp tseg22 tseg21 tseg20 tseg13 tseg12 tseg11 tseg10 write: reset:00000000 $0104 mscan12 receiver flag register (crflg) (3) see page 289. read: wupif rwrnif twrnif rerrif terrif boffif ovrif rxf write: reset:00000000 $0105 mscan12 receiver interrupt enable register (crier) (3) see page 291. read: wupie rwrnie twrnie rerrie terrie boffie ovrie rxfie write: reset:00000000 addr. register name bit 7654321bit 0 = unimplemented r = reserved u = unaffected notes: 1. available only on mc68hc912b32 and mc68hc912bc32 devices. 2. available only on mc68hc912b32 and mc68hc12be32 devices. 3. available only on mc68hc(9)12bc32 devices. figure 2-1. register map (sheet 16 of 19)
register block data sheet m68hc12b family ? rev. 9.0 58 register block motorola $0106 mscan12 transmitter flag register (ctflg) (3) see page 292. read: 0 abtak2 abtak1 abtak0 0 txe2 txe1 txe0 write: reset:00000111 $0107 mscan12 transmitter control register (ctcr) (3) see page 293. read: 0 abtrq2 abtrq1 abtrq0 0 txeie2 txeie1 txeie0 write: reset:00000000 $0108 mscan12 identifier acceptance control register (cidac) (3) see page 294. read: 0 0 idam1 idam0 0 idhit2 idhit1 idhit0 write: reset:00000000 $0109 reserved r r r r r r r r $010d reserved r r r r r r r r $010e mscan12 receive error counter (crxerr) (3) see page 295. read: rxerr7 rxerr6 rxerr5 rxerr4 rxerr3 rxerr2 rxerr1 rxerr0 write: reset:00000000 $010f mscan12 transmit error counter (ctxerr) (3) see page 295. read: txerr7 txerr6 txerr5 txerr4 txerr3 txerr2 txerr1 txerr0 write: reset:00000000 $0110 mscan12 identifier acceptance register 0 (cidar0) (3) see page 296. read: ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 write: reset: unaffected by reset $0111 mscan12 identifier acceptance register 1 (cidar1) (3) see page 296. read: ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 write: reset: unaffected by reset $0112 mscan12 identifier acceptance register 2 (cidar2) (3) see page 296. read: ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 write: reset: unaffected by reset $0113 mscan12 identifier acceptance register 3 (cidar3) (3) see page 296. read: ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 write: reset: unaffected by reset $0114 mscan12 identifier mask register 0 (cidmr0) (3) see page 297. read: am7 am6 am5 am4 am3 am2 am1 am0 write: reset: unaffected by reset $0115 mscan12 identifier mask register 1 (cidmr1) (3) see page 297. read: am7 am6 am5 am4 am3 am2 am1 am0 write: reset: unaffected by reset addr. register name bit 7654321bit 0 = unimplemented r = reserved u = unaffected notes: 1. available only on mc68hc912b32 and mc68hc912bc32 devices. 2. available only on mc68hc912b32 and mc68hc12be32 devices. 3. available only on mc68hc(9)12bc32 devices. figure 2-1. register map (sheet 17 of 19)
register block registers m68hc12b family ? rev. 9.0 data sheet motorola register block 59 $0116 mscan12 identifier mask register 2 (cidmr2) (3) see page 297. read: am7 am6 am5 am4 am3 am2 am1 am0 write: reset: unaffected by reset $0117 mscan12 identifier mask register 3 (cidmr3) (3) see page 297. read: am7 am6 am5 am4 am3 am2 am1 am0 write: reset: unaffected by reset $0118 mscan12 identifier acceptance register 4 (cidar4) (3) see page 296. read: ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 write: reset: unaffected by reset $0119 mscan12 identifier acceptance register 5 (cidar5) (3) see page 296. read: ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 write: reset: unaffected by reset $011a mscan12 identifier acceptance register 6 (cidar6) (3) see page 296. read: ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 write: reset: unaffected by reset $011b mscan12 identifier acceptance register 7 (cidar7) (3) see page 296. read: ac7 ac6 ac5 ac4 ac3 ac2 ac1 ac0 write: reset: unaffected by reset $011c mscan12 identifier mask register 4 (cidmr4) (3) see page 298. read: am7 am6 am5 am4 am3 am2 am1 am0 write: reset: unaffected by reset $011d mscan12 identifier mask register 5 (cidmr5) (3) see page 298. read: am7 am6 am5 am4 am3 am2 am1 am0 write: reset: unaffected by reset $011e mscan12 identifier mask register 6 (cidmr6) (3) see page 298. read: am7 am6 am5 am4 am3 am2 am1 am0 write: reset: unaffected by reset $011f mscan12 identifier mask register 7 (cidmr7) (3) see page 298. read: am7 am6 am5 am4 am3 am2 am1 am0 write: reset: unaffected by reset $0120 reserved r r r r r r r r $013c reserved r r r r r r r r $013d mscan12 port can control register (pctlcan) (3) see page 299. read:000000 puecan rdpcan write: reset:00000000 addr. register name bit 7654321bit 0 = unimplemented r = reserved u = unaffected notes: 1. available only on mc68hc912b32 and mc68hc912bc32 devices. 2. available only on mc68hc912b32 and mc68hc12be32 devices. 3. available only on mc68hc(9)12bc32 devices. figure 2-1. register map (sheet 18 of 19)
register block data sheet m68hc12b family ? rev. 9.0 60 register block motorola $013e mscan12 port can data register (portcan) (3) see page 299. read: pcan7 pcan6 pcan5 pcan4 pcan2 pcan2 txcan rxcan write: reset: unaffected by reset $013f mscan12 port can data direction register (ddrcan) (3) see page 300. read: ddrcan7 ddrcan6 ddrcan5 ddrcan4 ddrcan3 ddrcan2 00 write: reset:00000000 $0140 $014f receive buffer (rxfg) (3) ? see 16.3.2 receive structures $0150 $015f transmit buffer 0 (tx0) (3) ? see 16.3.3 transmit structures $0160 $016f transmit buffer 1 (tx1) (3) ? see 16.3.3 transmit structures $0170 $017f transmit buffer 2 (tx2) (3) ? see 16.3.3 transmit structures addr. register name bit 7654321bit 0 = unimplemented r = reserved u = unaffected notes: 1. available only on mc68hc912b32 and mc68hc912bc32 devices. 2. available only on mc68hc912b32 and mc68hc12be32 devices. 3. available only on mc68hc(9)12bc32 devices. figure 2-1. register map (sheet 19 of 19)
m68hc12b family ? rev. 9.0 data sheet motorola central processor unit (cpu) 61 data sheet ? m68hc12b family section 3. central processor unit (cpu) 3.1 introduction the cpu12 is a high-speed, 16-bit processor unit. it has full 16-bit data paths and wider internal registers (up to 20 bits) for high-speed extended math instructions. the instruction set is a proper superset of the m68hc11instruction set. the cpu12 allows instructions with odd byte counts , including many single-byte instructions. this provides efficient use of rom space. an instruction queue buffers program information so the cpu always has immedi ate access to at least three bytes of machine code at the start of every instruct ion. the cpu12 also offers an extensive set of indexed addressing capabilities. 3.2 programming model cpu12 registers are an integral part of the cpu and are not addressed as if they were memory locations. see figure 3-1 . figure 3-1. programming model 7 15 15 15 15 15 d x y sp pc ab n sxh i zvc 0 0 0 0 0 0 7 0 condition code register 8-bit accumulators a and b 16-bit double accumulator d (a : b) index register x index register y stack pointer program counter stop disable (ignore stop opcodes) carry overflow zero negative irq interrupt mask (disable) half-carry for bcd arithmetic xirq interrupt mask (disable)
central processor unit (cpu) data sheet m68hc12b family ? rev. 9.0 62 central processor unit (cpu) motorola 3.3 cpu registers this section describes the cpu registers. 3.3.1 accumulators a and b accumulators a and b are general-purpose 8-bit accumulators that contain operands and results of arithmetic ca lculations or data manipulations. 3.3.2 accumulator d accumulator d is the concatenation of accumulators a and b. some instructions treat the combination of these two 8-bit accumulators as a 16-bit double accumulator. note: the ldd and std instructions can be used to manipulate data in and out of accumulator d. bit 7654321bit 0 read: a7 a6 a5 a4 a3 a2 a1 a0 write: reset: unaffected by reset figure 3-2. accumulator a (a) bit 7654321bit 0 read: b7 b6 b5 b4 b3 b2 b1 b0 write: reset: unaffected by reset figure 3-3. accumulator b (b) bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 bit 0 read: d15 (a7) d14 (a6) d13 (a5) d12 (a4) d11 (a3) d10 (a2) d9 (a1) d8 (a0) d7 (b7) d6 (b6) d5 (b5) d4 (b4) d3 (b3) d2 (b2) d1 (b1) d0 (b0) write: reset: unaffected by reset figure 3-4. accumulator d (d)
central processor unit (cpu) cpu registers m68hc12b family ? rev. 9.0 data sheet motorola central processor unit (cpu) 63 3.3.3 index registers x and y index registers x and y are used for index ed addressing. indexed addressing adds the value in an index register to a constant or to the value in an accumulator to form the effective address of the operand. index registers x and y can also serve as temporary data storage locations. note: the ldx and stx instructions can be used to manipulate data in and out of index register x. note: the ldy and sty instructions can be used to manipulate data in and out of index register y. bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 bit 0 read: x15 x14 x13 x12 x11 x10 x9 x8 x7 x6 x5 x4 x3 x2 x1 x0 write: reset: unaffected by reset figure 3-5. index register x (x) bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 bit 0 read: y15 y14 y13 y12 y11 y10 y9 y8 y7 y6 y5 y4 y3 y2 y1 y0 write: reset: unaffected by reset figure 3-6. index register y (y)
central processor unit (cpu) data sheet m68hc12b family ? rev. 9.0 64 central processor unit (cpu) motorola 3.3.4 stack pointer the stack pointer (sp) contains the last stack address used. the cpu12 supports an automatic program stack that is used to save system cont ext during subroutine calls and interrupts. the stack pointer can also serve as a temporary data storage location or as an index register for indexed addressing. note: the lds and sts instructions can be used to manipulate data in and out of the stack pointer. 3.3.5 program counter the program counter contains the address of the next instruction to be executed. the program counter can also serve as an index register in all indexed addressing modes except autoincrement and autodecrement. bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 bit 0 read: sp15 sp14 sp13 sp12 sp11 sp10 sp9 sp8 sp7 sp6 sp5 sp4 sp3 sp2 sp1 sp0 write: reset: unaffected by reset figure 3-7. stack pointer (sp) bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 bit 0 read: sp15 sp14 sp13 sp12 sp11 sp10 sp9 sp8 sp7 sp6 sp5 sp4 sp3 sp2 sp1 sp0 write: reset: unaffected by reset figure 3-8. program counter (pc)
central processor unit (cpu) data types m68hc12b family ? rev. 9.0 data sheet motorola central processor unit (cpu) 65 3.3.6 condition code register s ? stop disable bit setting the s bit disables the stop instruction. x ? xirq interrupt mask bit setting the x bit masks interru pt requests from the xirq pin. h ? half-carry flag the h flag is used only for bcd arithmetic operations. it is set when an aba, add, or adc instruction produces a carry from bit 3 of accumulator a. the daa instruction uses the h flag and the c flag to adjust the result to the correct bcd format. i ? interrupt mask bit setting the i bit disables maskable interrupt sources. n ? negative flag the n flag is set when the result of an operation is less than 0. z ? zero flag the z flag is set when the result of an operation is all 0s. v ? two?s complement overflow flag the v flag is set when a two?s complement overflow occurs. c ? carry/borrow flag the c flag is set when an addition or subtraction operation produces a carry or borrow. 3.4 data types the cpu12 supports four data types: 1. bit data 2. 8-bit and 16-bit signed and unsigned integers 3. 16-bit unsigned fractions 4. 16-bit addresses a byte is eight bits wide and can be ac cessed at any byte location. a word is composed of two consecutive bytes with the most significant byte at the lower value address. there are no special requirements for alignment of instructions or operands. bit 7654321bit 0 read: sxh i nzvc write: reset:1 1u1uuuu u = unaffected figure 3-9. condition code register (ccr)
central processor unit (cpu) data sheet m68hc12b family ? rev. 9.0 66 central processor unit (cpu) motorola 3.5 addressing modes addressing modes determine how the cp u accesses memory locations to be operated upon. the cpu12 includes all of the addressing modes of the m68hc11 cpu as well as several new forms of indexed addressing. table 3-1 is a summary of the availabl e addressing modes. table 3-1. addressing mode summary addressing mode source forma t abbreviation description inherent inst inh operands (if any) are in cpu registers. immediate inst # opr8i or inst # opr16i imm operand is included in instruction stream 8- or 16-bit size implied by context. direct inst opr8a dir operand is the lower 8 bits of an address in the range $0000?$00ff. extended inst opr16a ext operand is a 16-bit address. relative inst rel8 or inst rel16 rel an 8-bit or 16-bit relative offset from the current pc is supplied in the instruction. indexed 5-bit offset inst oprx5 , xysp idx 5-bit signed constant offset from x, y, sp, or pc indexed auto pre-decrement inst oprx3 , ?xys idx auto pre-decrement x, y, or sp by 1 ~ 8 indexed auto pre-increment inst oprx3 , +xys idx auto pre-increment x, y, or sp by 1 ~ 8 indexed auto post- decrement inst oprx3 , xys? idx auto post-decrement x, y, or sp by 1 ~ 8 indexed auto post-increment inst oprx3 , xys+ idx auto post-increment x, y, or sp by 1 ~ 8 indexed accumulator offset inst abd , xysp idx indexed with 8-bit (a or b) or 16-bit (d) accumulator offset from x, y, sp, or pc indexed 9-bit offset inst oprx9 , xysp idx1 9-bit signed constant offset from x, y, sp, or pc (lower 8 bits of offset in one extension byte) indexed 16-bit offset inst oprx16 , xysp idx2 16-bit constant offset from x, y, sp, or pc (16-bit offset in two extension bytes) indexed-indirect 16-bit offset inst [ oprx16 , xysp ][idx2] pointer to operand is found at 16-bit constant offset from x, y, sp, or pc (16-bit offset in two extension bytes) indexed-indirect d accumulator offset inst [d, xysp ][d,idx] pointer to operand is found at x, y, sp, or pc plus the value in d
central processor unit (cpu) indexed addressing modes m68hc12b family ? rev. 9.0 data sheet motorola central processor unit (cpu) 67 3.6 indexed addressing modes the cpu12 indexed modes reduce execution time and eliminate code size penalties for using the y index regi ster. cpu12 indexed addressing uses a postbyte plus zero, one, or two extension bytes after the instruction opcode. the postbyte and extensions do these tasks:  specify which index register is used  determine whether a value in an accumulator is used as an offset  enable automatic pre- or post-increment or decrement  specify use of 5-bit, 9-bit, or 16-bit signed offsets 3.7 opcodes and operands the cpu12 uses 8-bit opcodes. each opcode identifies a particular instruction and associated addressing mode to the cpu. several opcodes are required to provide each instruction with a range of addressing capabilities. only 256 opcodes would be available if the range of values were restricted to the number that can be represented by 8- bit binary numbers. to expand the number table 3-2. summary of indexed operations postbyte code (xb) source code syntax comments rr0nnnnn ,r n,r ?n,r 5-bit constant offset n = ?16 to +15 r can specify x, y, sp, or pc 111rr0zs n,r ?n,r constant offset (9- or 16-bit signed) z:0 = 9-bit with sign in lsb of postbyte(s) 1 = 16-bit if z = s = 1, 16-bit offset indexed-indirect (see below) rr can specify x, y, sp, or pc 111rr011 [n,r] 16-bit offset indexed-indirect rr can specify x, y, sp, or pc rr1pnnnn n,?r n,+r n,r? n,r+ auto pre-decrement/increment or auto post-decrement/increment ; p = pre-(0) or post-(1), n = ?8 to ?1, +1 to +8 rr can specify x, y, or sp (pc not a valid choice) 111rr1aa a,r b,r d,r accumulator offset (unsigned 8-bit or 16-bit) aa:00 = a 01 = b 10 = d (16-bit) 11 = see accumulator d offset indexed-indirect rr can specify x, y, sp, or pc 111rr111 [d,r] accumulator d offset indexed-indirect rr can specify x, y, sp, or pc rr: 00 = x, 01 = y, 10 = sp, 11 = pc
central processor unit (cpu) data sheet m68hc12b family ? rev. 9.0 68 central processor unit (cpu) motorola of opcodes, a second page is added to the opcode map. opcodes on the second page are preceded by an additional byte with the value $18. to provide additional addres sing flexibility, opcodes c an also be followed by a postbyte or extension bytes. postby tes implement certain forms of indexed addressing, transfers, exchanges, and loop primitives. extension bytes contain additional program information such as addresses, offsets, and immediate data.
m68hc12b family ? rev. 9.0 data sheet motorola resets and interrupts 69 data sheet ? m68hc12b family section 4. resets and interrupts 4.1 introduction resets and interrupts are exceptions. each exception has a 16-bit vector that points to the memory location of the associated exception-handling routine. vectors are stored in the upper 128 bytes of the standard 64-kbyte address map. the six highest vector addresses are us ed for resets and non-maskable interrupt sources. the remainder of the vectors are used for maskable interrupts, and all must be initialized to point to the address of the appropriate service routine. 4.2 exception priority a hardware priority hierarchy determines which reset or interrupt is serviced first when simultaneous requests are made. six sources are not maskable. the remaining sources are maskable, and any one of them can be given priority over other maskable interrupts. the priorities of the non-maskable sources are: 1. power-on reset (por) or reset pin 2. clock monitor reset 3. computer operating properly (cop) watchdog reset 4. unimplemented instruction trap 5. software interrupt instruction (swi) 6. xirq signal if x bit in ccr = 0 4.3 maskable interrupts maskable interrupt sources include on-c hip peripheral syst ems and external interrupt service requests. interrupts fr om these sources ar e recognized when the global interrupt mask bit (i) in the condi tion code register (ccr) is cleared. the default state of the i bit out of reset is 1, but it can be written at any time. interrupt sources are prioritized by default but any one maskable interrupt source may be assigned the highest prio rity by means of the hprio register. the relative priorities of the other sources remain the same.
resets and interrupts data sheet m68hc12b family ? rev. 9.0 70 resets and interrupts motorola an interrupt that is assigned highest priori ty is still subject to global masking by the i bit in the ccr or by any associated loca l bits. interrupt vectors are not affected by priority assignment. hprio can be writte n only while the i bit is set (interrupts inhibited). table 4-1 lists interrupt sources and vectors in default order of priority for all devices except the mc68hc(9)12bc32. table 4-2 lists the interrupt sources and vectors for the mc68hc(9)12bc32. table 4-1. interrupt vector map (1) vector address interrupt source ccr mask local enable hprio value to elevate to highest i bit register bit(s) $fffe, $ffff reset none none none ? $fffc, $fffd cop clock monitor fail reset none copctl cme, fcme ? $fffa, $fffb cop failure reset none none cop rate selected ? $fff8, $fff9 unimplemented in struction trap none none none ? $fff6, $fff7 swi none none none ? $fff4, $fff5 xirq x bit none none ? $fff2, $fff3 irq i bit intcr irqen $f2 $fff0, $fff1 real-time inte rrupt i bit rtictl rtie $f0 $ffee, $ffef timer channel 0 i bit tmsk1 c0i $ee $ffec, $ffed timer channel 1 i bit tmsk1 c1i $ec $ffea, $ffeb timer channel 2 i bit tmsk1 c2i $ea $ffe8, $ffe9 timer channel 3 i bit tmsk1 c3i $e8 $ffe6, $ffe7 timer channel 4 i bit tmsk1 c4i $e6 $ffe4, $ffe5 timer channel 5 i bit tmsk1 c5i $e4 $ffe2, $ffe3 timer channel 6 i bit tmsk1 c6i $e2 $ffe0, $ffe1 timer channel 7 i bit tmsk1 c7i $e0 $ffde, $ffdf timer overflow i bit tmsk2 toi $de $ffdc, $ffdd pulse accumulato r overflow i bit pactl paovi $dc $ffda, $ffdb pulse accumulator input edge i bit pactl pai $da $ffd8, $ffd9 spi serial transfer complete i bit sp0cr1 spie $d8 $ffd6, $ffd7 sci 0 i bit sc0 cr2 tie, tcie, rie, ilie $d6 $ffd4, $ffd5 reserved i bit ? ? $d4 $ffd2, $ffd3 atd i bit atdctl2 ascie $d2 $ffd0, $ffd1 bdlc i bit bcr1 ie $d0 $ff80?$ffc1 reserved (not implemented) i bit ? ? $80?$c0 $ffc2?$ffc9 reserved (implemented) i bit ? ? $c2?$c8 $ffca, $ffcb pulse accumulator b overflow i bit pbctl pbovi $ca $ffcc, $ffcd modulus down counter underflow i bit mcctl mczi $cc $ffce, $ffcf reserved (implemented) i bit ? ? $ce 1. see table 4-2 for the mc68hc(9)12bc32 interrupt vector map.
resets and interrupts latching of interrupts m68hc12b family ? rev. 9.0 data sheet motorola resets and interrupts 71 4.4 latching of interrupts xirq is always level triggered and irq can be selected as a level-triggered interrupt. these level-triggered interrupt pins should be released only during the appropriate interrupt service routine. gener ally, the interrupt service routine will handshake with the interrupting logic to release the pin. in this way, the mcu will table 4-2. mc68hc(9)12bc32 interrupt vector map vector address interrupt source ccr mask local enable hprio value to elevate to highest i bit register bit(s) $fffe, $ffff reset none none none ? $fffc, $fffd cop clock monitor fail reset none copctl cme, fcme ? $fffa, $fffb cop failure reset none none cop rate selected ? $fff8, $fff9 unimplemented in struction trap none none none ? $fff6, $fff7 swi none none none ? $fff4, $fff5 xirq x bit none none ? $fff2, $fff3 irq i bit intcr irqen $f2 $fff0, $fff1 real-time inte rrupt i bit rtictl rtie $f0 $ffee, $ffef timer channel 0 i bit tmsk1 c0i $ee $ffec, $ffed timer channel 1 i bit tmsk1 c1i $ec $ffea, $ffeb timer channel 2 i bit tmsk1 c2i $ea $ffe8, $ffe9 timer channel 3 i bit tmsk1 c3i $e8 $ffe6, $ffe7 timer channel 4 i bit tmsk1 c4i $e6 $ffe4, $ffe5 timer channel 5 i bit tmsk1 c5i $e4 $ffe2, $ffe3 timer channel 6 i bit tmsk1 c6i $e2 $ffe0, $ffe1 timer channel 7 i bit tmsk1 c7i $e0 $ffde, $ffdf timer overflow i bit tmsk2 toi $de $ffdc, $ffdd pulse accumulato r overflow i bit pactl paovi $dc $ffda, $ffdb pulse accumulator input edge i bit pactl pai $da $ffd8, $ffd9 spi serial transfer complete i bit sp0cr1 spie $d8 $ffd6, $ffd7 sci 0 i bit sc0 cr2 tie, tcie, rie, ilie $d6 $ffd4, $ffd5 reserved i bit ? ? $d4 $ffd2, $ffd3 atd i bit atdctl2 ascie $d2 $ffd0, $ffd1 mscan wa keup i bit crier wupie $d0 $ffca?$ffcf reserved (not implemented) i bit ? ? $ca?$cf $ffc8?$ffc9 mscan errors i bit crier rwrnie, twrnie, rerrie, terrie, boffie, ovrie $c8 $ffc6, $ffc7 mscan rece ive i bit crier rxfie $c6 $ffc4, $ffc5 mscan transmit i bit ctcr txeie[2:0] $c4 $ff80, $ffc3 reserved (implemented) i bit ? ? $80?$c3
resets and interrupts data sheet m68hc12b family ? rev. 9.0 72 resets and interrupts motorola never start the interrupt service sequence only to determine that there is no longer an interrupt source. in the event that this does occur, the trap vector will be taken. if irq is selected as an edge-triggered interrupt, the hold time of the level after the active edge is independent of when the interrupt is serviced. as long as the minimum hold time is met, the interrupt will be latched inside the mcu. in this case, the irq edge interrupt latch is cleared automat ically when the interrupt is serviced. all of the remaining interrupts are latched by the mcu with a flag bit. these interrupt flags should be cleared during an interrupt service routine or when the interrupts are masked by the i bit. by doing this, the mcu will never get an unknown interrupt source and take the trap vector. 4.5 interrupt control and priority registers this section describes the interrupt control and priority registers. 4.5.1 interrupt control register read: anytime write: varies from bit to bit irqe ? irq edge-sensitive only bit irqe can be written once in normal modes. in special modes, irqe can be written anytime, but the first write is ignored. 1 = irq pin responds only to falling edges. 0 = irq pin responds to low levels. irqen ? external irq enable bit irqen can be written anytime in all modes. the irq pin has an internal pullup. 1 = irq pin connected to interrupt logic 0 = irq pin disconnected from interrupt logic dly ? oscillator startup delay on exit from stop mode bit dly can be written once in normal modes. in special modes, dly can be written anytime. the delay time of about 4096 cycles is based on the e-clock rate. 1 = stabilization delay on exit from stop mode 0 = no stabilization delay on exit from stop mode address: $001e bit 7654321bit 0 read: irqeirqendly00000 write: reset:01100000 figure 4-1. interrupt control register (intcr)
resets and interrupts resets m68hc12b family ? rev. 9.0 data sheet motorola resets and interrupts 73 4.5.2 highest priority i interrupt register read: anytime write: only if i bit in ccr = 1 (interrupts inhibited) to give a maskable interrupt source highest priority, write the low byte of the vector address to the hprio register. for example, writing $f0 to hprio assigns highest maskable interrupt priority to the real-time interrupt timer ($fff0). if an unimplemented vector address or a non-i- masked vector address (a value higher than $f2) is written, then irq is the default highest priority interrupt. 4.6 resets there are four possible sources of re set. por and external reset on the reset pin share the normal reset vector. cop re set and the clock monitor reset each has a vector. entry into reset is asynchronous and does not require a clock, but the mcu cannot sequence out of reset without a system clock. 4.6.1 power-on reset (por) a positive transition on v dd causes a por. an external voltage level detector or other external reset circuits are the usual source of reset in a system. the por circuit only initializes internal circuitry du ring cold starts and cannot be used to force a reset as system voltage drops. 4.6.2 external reset the cpu distinguishes between internal and external reset c onditions by sensing whether the reset pin rises to a logic 1 in less than eight e-clock cycles after an internal device releases reset. when a reset condit ion is sensed, the reset pin is driven low by an internal device for about 16 e-clock cycles, then released. eight e-clock cycles later it is sampled. if the pi n is still held low, the cpu assumes that an external reset has occurred. if the pin is high, it indicates that the reset was initiated internally by either the cop system or the clock monitor. to prevent a cop or clock monitor rese t from being detected during an external reset, hold the reset pin low for at least 32 cycles. an external resistor-capacitor (rc) power-up delay circuit on the reset pin is not recommended because circuit charge time can cause the mcu to misinter pret the type of reset that has occurred. address: $001f bit 7654321bit 0 read: 1 1 psel5 psel4 psel3 psel2 psel1 0 write: reset:11110010 figure 4-2. highest priority i interrupt register (hprio)
resets and interrupts data sheet m68hc12b family ? rev. 9.0 74 resets and interrupts motorola 4.6.3 computer operating properly (cop) reset the mcu includes a cop system to help protect against software failures. when cop is enabled, software must write $55 and $aa (in this order) to the coprst register to keep a watchdog timer from timing out. other instructions may be executed between these writes. a write of any value other than $55 or $aa or software failing to execute the sequence pr operly causes a cop reset to occur. 4.6.4 clock monitor reset if clock frequency falls below a predetermi ned limit when the clock monitor is enabled, a reset occurs. 4.7 effects of reset when a reset occurs, mcu registers and control bits are changed to known startup states, as described here. 4.7.1 operating mode and memory map the states of the bkgd, moda, and modb pins during reset determine the operating mode and default memory mapping. the smodn, moda, and modb bits in the mode register reflect the stat us of the mode-select inputs at the rising edge of reset. operating mode and default maps can subsequently be changed according to strictly defined rules. 4.7.2 clock and watchdog control logic reset enables the cop watchdog with the cr2?cr0 bits set for the shortest timeout period. the clock monitor is disabled. the rtif flag is cleared and automatic hardware interrupts are masked. the rate control bits are cleared and must be initialized before the return-fro m-interrupt (rti) system is used. the dly control bit is set to specify an oscillator startup delay upon recovery from stop mode. 4.7.3 interrupts reset initializes the hprio register with the value $f2, causing the irq pin to have the highest i-bit interrupt priority. the irq pin is configured for level-sensitive operation (for wired-or systems). however, the i and x bits in the ccr are set, masking irq and xirq interrupt requests.
resets and interrupts interrupt recognition m68hc12b family ? rev. 9.0 data sheet motorola resets and interrupts 75 4.7.4 parallel input/output (i/o) if the mcu comes out of reset in an expanded mode, port a and port b are the multiplexed address/data bus. port e pins are normally used to control the external bus. the port e assignment register (pear) affects port e pin operation. if the mcu comes out of reset in a single-chip mode, all ports are configured as general-purpose high-impedance inputs. 4.7.5 central processing unit (cpu) after reset, the cpu fetches a vector from the appropriate address and begins executing instructions. the stack pointer and other cpu registers are indeterminate immediately after reset. th e condition code register (ccr) x and i interrupt mask bits are set to mask any in terrupt requests. the s bit is also set to inhibit the stop instruction. 4.7.6 memory after reset, the internal register block is located at $0000?$01ff, the register-following space is at $0200?$03ff, and ram is at $0800?$0bff. eeprom is located at $0d00?$0fff. flash eeprom/rom is located at $8000?$ffff in single-chip modes and at $0000?$7fff (but disabled) in expanded modes. 4.7.7 other resources the timer, serial communications interface (sci), serial peripheral interface (spi), byte data link controller (bdlc), pulse- width modulator (pwm), analog-to-digital converter (atd), and motorola scalable co ntroller area network (mscan) are off after reset. 4.8 interrupt recognition once enabled, an interrupt request can be recognized at any time after the i bit in the ccr is cleared. when an interrupt requ est is recognized, the cpu responds at the completion of the instruction being exec uted. interrupt latency varies according to the number of cycles required to complete the instruction. some of the longer instructions can be interrupted and resume normally after servicing the interrupt. when the cpu begins to service an interrupt request, it:  clears the instruction queue  calculates the return address  stacks the return address and the contents of the cpu registers as shown in table 4-3
resets and interrupts data sheet m68hc12b family ? rev. 9.0 76 resets and interrupts motorola after stacking the ccr, the cpu:  sets the i bit to prevent other interrupts from disrupting the interrupt service routine  sets the x bit if an xirq interrupt request is pending  fetches the interrupt vector for the highest-priority request that was pending at the beginning of the interrupt sequence  begins execution of the interrupt service routine at the location pointed to by the vector if no other interrupt request is pending at the end of the interrupt service routine, a return-from-interrupt (rti) instruction recovers the stacked values. program execution resumes program at the return address. if another interrupt request is pending at the end of an interrupt service routine, the rti instruction recovers the stacked values. however, the cpu then:  adjusts the stack pointer to point ag ain at the stacked ccr location, sp ? 9  fetches the vector of the pending interrupt  begins execution of the interrupt service routine at the location pointed to by the vector table 4-3. stacking order on entry to interrupts memory location stacked values sp ? 2 rtn h : rtn l sp ? 4 y h : y l sp ? 6 x h : x l sp ? 8 b : a sp ? 9 ccr
m68hc12b family ? rev. 9.0 data sheet motorola operating modes and resource mapping 77 data sheet ? m68hc12b family section 5. operating modes and resource mapping 5.1 introduction the mcu can operate in eight different modes. each mode has a different default memory map and external bus configurati on. after reset, most system resources can be mapped to other addresses by writing to the appropriate control registers. 5.2 operating modes the states of the bkgd, modb, and moda pins during reset determine the operating mode after reset. the smodn, modb, and moda bits in the mode register show current operating mode and provide limited mode switching during operation. the states of the bkgd, modb, and moda pins are latched in to these bits on the rising edge of the reset signal. during reset an active pullup is connected to the bkgd pin (as input) and active pulldowns are connected to the modb and moda pins. if an open occurs on any of these pins, the device will operate in normal single-chip mode. table 5-1. mode selection bkgd modb moda mode port a port b 0 0 0 special single chip general- purpose i/o general- purpose i/o 0 0 1 special expanded narrow addr[15:8] data[7:0] addr[7:0] 0 1 0 special peripheral addr data addr data 0 1 1 special expanded wide addr data addr data 1 0 0 normal single chip general- purpose i/o general- purpose i/o 1 0 1 normal expanded narrow addr[15:8] data[7:0] addr[7:0] 110 reserved (forced to peripheral) ?? 1 1 1 normal expanded wide addr data addr data
operating modes and resource mapping data sheet m68hc12b family ? rev. 9.0 78 operating modes and resource mapping motorola the two basic types of operating modes are: 1. normal modes ? some registers and bi ts are protected against accidental changes. 2. special modes ? protected control registers and bits are allowed greater access for special purposes such as testing and emulation. a system development and debug feat ure, background debug mode (bdm) is available in all modes. in s pecial single-chip mode, bdm is active immediately after reset. 5.2.1 normal operating modes these modes provide three operating configurations. background debugging is available in all three modes, but must first be enabled for some operations by means of a bdm command. bdm can th en be made active by another bdm command. 5.2.1.1 normal expanded wide mode the 16-bit external address and data buses use ports a and b. addr15?addr8 and data15?data8 are multiplexed on port a. addr7?addr0 and data7?data0 are multiplexed on port b. 5.2.1.2 normal expanded narrow mode the 16-bit external address bus uses port a for the high byte and port b for the low byte. the 8-bit external data bus uses port a. addr15?addr8 and data7?data0 are multiplexed on port a. 5.2.1.3 normal single-chip mode normal single-chip mode has no external buses. ports a, b, and e are configured for general-purpose input/output (i/o). port e bits 1 and 0 are input only with internal pullups and the other 22 pins are bi directional i/o pins that are initially configured as high-impedance inputs. port e pullups are enabled on reset. port a and b pullups are disabled on reset. 5.2.2 special operating modes special operating modes are commonly used in factory testing and system development. 5.2.2.1 special expanded wide mode this mode is for emulation of norm al expanded wide mode and emulation of normal single-chip mode with a 16-bit bus. the bus-control pins of port e are all configured for their bus-control output functions rather than general-purpose i/o.
operating modes and resource mapping operating modes m68hc12b family ? rev. 9.0 data sheet motorola operating modes and resource mapping 79 5.2.2.2 special expanded narrow mode this mode is for emulation of normal expanded narrow mode. external 16-bit data is handled as two back-to-back bus cycl es, one for the high byte followed by one for the low byte. internal operations continue to use full 16-bit data paths. 5.2.2.3 special single-chip mode this mode can be used to force the mcu to active bdm mode to allow system debug through the bkgd pin. the mcu does not fetch the reset vector and execute application code as it would in other modes. instead, the active background mode is in control of cpu execution and bdm firmware waits for additional serial commands through the bkg d pin. there are no external address and data buses in this mode. the mcu operates as a stand-alone device and all program and data space are on-chip. external port pins can be used for general-purpose i/o. 5.2.2.4 special peripheral mode the cpu is not active in this mode. an external master can control on-chip peripherals for testing purposes. it is not possible to change to or from this mode without going through reset. background debugging should not be used while the mcu is in special peripheral mode as in ternal bus conflicts between bdm and the external master can cause im proper operation of both modes. 5.2.3 background debug mode background debug mode (bdm) is an auxili ary operating mode that is used for system development. bdm is implemented in on-chip hardware and provides a full set of debug operations. some bdm commands can be executed while the cpu is operating normally. other bdm commands are firmware based and require the bdm firmware to be enabled and active for execution. in special single-chip mode, bdm is enabled and active immediately out of reset. bdm is available in all other operating modes, but must be enabled before it can be activated. bdm should not be used in special peripheral mode because of potential bus conflicts. once enabled, background mode can be made active by a serial command sent via the bkgd pin or execution of a cpu12 bgnd instruction. while background mode is active, the cpu can interpret special debugging commands, read and write cpu registers, peripheral registers, and locations in memory. while bdm is active, the cpu executes code located in a small on-chip rom mapped to addresses $ff00 to $ffff; bdm control registers are accessible at addresses $ff00 to $ff06. the bdm rom replaces the regular system vectors while bdm is active. while bdm is active, the user memory from $ff00 to $ffff is not in the map except through serial bdm commands.
operating modes and resource mapping data sheet m68hc12b family ? rev. 9.0 80 operating modes and resource mapping motorola bdm allows read and write access to internal memory-mapped registers and ram and read access to eeprom, flash eeprom , or rom without interrupting the application code executing in the cpu. this non-intrusive mode uses dead bus cycles to access the memory and in most cases will remain cycle deterministic. refer to 18.3 background debug mode (bdm) for more details. 5.3 internal resource mapping the internal register block, ra m, flash eeprom/rom, and eeprom have default locations within the 64-kbyte standard address space but may be reassigned to other locations during program execution by setting bits in mapping registers initrg, initrm, and initee. during normal operating modes, these registers can be written once. it is advisable to explicitly establish these resource locations during the initialization phase of pr ogram execution, even if default values are chosen, to protect the registers from inadvertent modification later. writes to the mapping registers go into effect between the cycle that follows the write and the cycle after that. to assure that there are no unintended operations, a write to one of these registers should be followed with a no operation (nop) instruction. if conflicts occur when mapping resources, the register block will take precedence over the other resources; ram, fl ash eeprom/rom, or eeprom addresses occupied by the register block will not be available for storage. when active, bdm rom takes precedence over other resources, although a conflict between bdm rom and register space is not possible. table 5-2 shows resource mapping precedence. in expanded modes, all address space not ut ilized by internal resources is by default external memory. 5.4 mode and resour ce mapping registers this section describes the mode and resource mapping registers. table 5-2. mapping precedence precedence resource 1 bdm rom (if active) 2 register space 3ram 4 eeprom 5 flash eeprom/rom 6 external memory
operating modes and resource mapping mode and resource mapping registers m68hc12b family ? rev. 9.0 data sheet motorola operating modes and resource mapping 81 5.4.1 mode register the mode register (mode) controls the mcu operating mode and various configuration options. this register is not in the map in peripheral mode. read: anytime write: varies from bit to bit smodn, modb, moda ? mode select special, b, and a bits these bits show the current operating mode and reflect the status of the bkgd, modb, and moda input pins at the rising edge of reset. smodn can be written only if smodn = 0 (in special modes) but the first write is ignored; modb, moda may be written once if smodn = 1; anytime if smodn = 0, except that special peri pheral and reserved modes cannot be selected. estr ? e clock stretch enable bit estr determines if the e clock behaves as a simple free-running clock or as a bus control signal that is active only fo r external bus cycles. estr is always 1 in expanded modes since it is required for address demultiplexing and must follow stretched cycles. 1 = e stretches high during external acce ss cycles and low during non-visible internal accesses 0 = e never stretches (always free running) normal modes: write once special modes: write anytime ivis ? internal visibility bit ivis determines whether internal addr/data, r/w , and lstrb signals can be seen on the bus during accesses to internal locations. in special expanded narrow mode, it is possible to configure the mcu to show internal accesses on an external 16-bit bus. the ivis control bit must be set to 1. when the system is configured this way, visible internal accesses are shown as if the mcu was address: $000b bit 7654321bit 0 read: smodn modb moda estr ivis ebswai 0 eme write: reset states: normal expanded narrow:10110000 normal expanded wide:11110000 special expanded narrow:00111001 special expanded wide:01111001 peripheral:01011001 normal single-chip:10010000 special single-chip:00011001 figure 5-1. mode register (mode)
operating modes and resource mapping data sheet m68hc12b family ? rev. 9.0 82 operating modes and resource mapping motorola configured for expanded wide mode, but no rmal external accesses operate as if the bus in narrow mode. in normal expanded narrow mode, internal visibility is not allowed and ivis is ignored. 1 = internal bus operations visible on external bus 0 = no visibility of internal bus operations on external bus normal modes: write once special modes: write anytime except the first time ebswai ? external bus module stop in wait bit this bit controls access to the external bus interface when in wait mode. the module delays before shutting down in wait mode to allow for final bus activity to complete. 1 = external bus shut down during wait mode 0 = external bus and registers continue functioning in wait mode. normal modes: write anytime special modes: write never eme ? emulate port e bit removing the registers from the map allows the user to emulate the function of these registers externally. in single-chip mode, port e data register (porte) and port e data direction register (ddre) are always in the map regardless of the state of this bit. 1 = porte and ddre removed from the memory map (expanded mode) 0 = porte and ddre in the memory map normal modes: write once special modes: write anytime except the first time 5.4.2 register initialization register after reset, the 512-byte register block resides at location $0000 but can be reassigned to any 2-kbyte boundary within the standard 64-kbyte address space. mapping of internal registers is controlled by five bits in the register initialization register (initrg). the register block occu pies the first 512 bytes of the 2-kbyte block. read: anytime write: once in normal modes; anytime in special modes reg15?reg11 ? register position bits these bits specify the upper five bits of the 16-bit register address. address: $0011 bit 7654321bit 0 read: reg15 reg14 reg13 reg12 reg11 0 0 mmswai write: reset:00000000 figure 5-2. register initialization register (initrg)
operating modes and resource mapping mode and resource mapping registers m68hc12b family ? rev. 9.0 data sheet motorola operating modes and resource mapping 83 mmswai ? memory mapping interface stop in wait control bit this bit controls access to the memory mapping interface when in wait mode. 0 = memory mapping interface continues to function in wait mode. 1 = memory mapping interface access shuts down in wait mode. normal modes: write anytime special modes: write never 5.4.3 ram initialization register after reset, addresses of the 1-kbyte ram array begin at location $0800 but can be assigned to any 2-kbyte boundary within the standard 64-kbyte address space. mapping of internal ram is controlled by five bits in the ram initialization register (initrm). the ram array occupies the first 1 kbyte of the 2-kbyte block. read: anytime write: once in normal modes; anytime in special modes ram15?ram11 ? ram position bits these bits specify the upper five bits of the 16-bit ram address. 5.4.4 eeprom initialization register the mcu has 768 bytes of eeprom which ar e activated by the eeon bit in the eeprom initialization register (initee). mapping of internal eeprom is controlled by four bits in the initee register. after reset, eeprom address space begins at lo cation $0d00 but c an be mapped to any 4-kbyte boundary within the standard 64-kbyte address space. read: anytime write: varies from bit to bit address: $0010 bit 7654321bit 0 read: ram15 ram14 ram13 ram12 ram11 0 0 0 write: reset:00001000 figure 5-3. ram initialization register (initrm) address: $0012 bit 7654321bit 0 read: ee15 ee14 ee13 ee12 0 0 0 eeon write: reset:00000001 figure 5-4. eeprom initialization register (initee)
operating modes and resource mapping data sheet m68hc12b family ? rev. 9.0 84 operating modes and resource mapping motorola ee15?ee12 ? internal eeprom position bits these bits specify the upper four bi ts of the 16-bit eeprom address. write once in normal modes or anytime in special modes. eeon ? eeprom on bit eeon allows read access to the eepr om array. eeprom control registers can be accessed and eeprom locati ons can be programmed or erased regardless of the state of eeon. eeon is forced to 1 in single-chip modes. write only in expanded and peripheral modes. 1 = eeprom in memory map 0 = eeprom removed from memory map 5.4.5 miscellaneous mapping control register additional mapping controls are availabl e that can be used in conjunction with flash eeprom/rom and memory expansion. the 32-kbyte flash eeprom/rom can be mapped to either the upper or lower half of the 64-kbyte address space. when mappi ng conflicts occur, registers, ram, and eeprom have priority over flash eeprom. note: only the mc68hc912b32 contains flash eeprom. the mc68hc12be32 contains rom. to use memory expansion, the part must be operated in one of the expanded modes. read: anytime write: once in normal modes; anytime in special modes ndrf ? narrow data bus for register-following map bit this bit enables a narrow bus feature for the 512-byte register-following map. in expanded narrow (8-bit) modes, single- chip modes, and peripheral mode, ndrf has no effect. the register-followi ng map always begins at the byte following the 512-byte register map. if the registers are moved, this space moves also. 1 = register-following map space acts the same as an 8-bit external data bus. 0 = register-following map space acts as a full 16-bit external data bus. address: $0013 bit 7654321bit 0 read: 0 ndrf rfstr1 rfstr0 exstr1 exstr0 maprom romon write: reset states: expanded modes:00001100 single-chip modes:00001111 figure 5-5. miscellaneous mapping control register (misc)
operating modes and resource mapping mode and resource mapping registers m68hc12b family ? rev. 9.0 data sheet motorola operating modes and resource mapping 85 rfstr1 and rfstr0 ? register-following stretch bits these bits determine the amount of clock stretch on accesses to the 512-byte register-following map. it is valid regardless of the state of the ndrf bit. in single-chip and peripheral modes, these bits have no meaning or effect. see table 5-3 . exstr1 and exstr0 ? external access stretch bit 1 and bit 0 these bits determine the amount of clock stretch on accesses to the external address space. in single-chip and peripheral modes, these bits have no meaning or effect. maprom ? flash eeprom/rom map bit this bit determines the location of the on-chip flash eeprom/rom. in expanded modes, it is reset to 0. in single-chip modes, it is reset to 1. if romon is 0, this bit has no meaning or effect. 1 = flash eeprom/rom is lo cated from $8000 to $ffff. 0 = flash eeprom/rom is lo cated from $0000 to $7fff. romon ? flash eeprom/rom enable bit in expanded modes, romon is reset to 0. in single-chip modes, it is reset to 1. if the internal ram, registers, eeprom, or bdm rom (if active) are mapped to the same space as the flash eeprom/rom , they will have priority over the flash eeprom/rom. 1 = enables the flash eeprom/rom in the memory map 0 = disables the flash eepr om/rom in the memory map table 5-3. register-following stretch bit function rfstr1 and rfstr0 e clocks stretched 00 0 01 1 10 2 11 3 table 5-4. expanded stretch bit function exstr1 and exstr0 e clocks stretched 00 0 01 1 10 2 11 3
operating modes and resource mapping data sheet m68hc12b family ? rev. 9.0 86 operating modes and resource mapping motorola 5.5 memory map figure 5-6 illustrates the memory map for each mode of operation immediately after reset. figure 5-6. memory map bdm if active $8000 $ffff $ffff flash eeprom/rom $0000 $0800 $0d00 $0fff $ff00 $0000 $01ff $0800 single-chip special single-chip normal expanded $8000 vectors vectors vectors $ff00 $f000 768 bytes eeprom map to any 4-k space 1-kbyte ram map to any 2-k space registers map to any 2-k space $ffff $ffc0 $0bff map with maprom bit $0d00 512 bytes $0000 $7fff in misc register to $0000?$7fff or $8000?$ffff $0200 $03ff register following space 512 bytes
m68hc12b family ? rev. 9.0 data sheet motorola bus control and input/output (i/o) 87 data sheet ? m68hc12b family section 6. bus control and input/output (i/o) 6.1 introduction internally, the mcu has full 16-bit data paths, but depending upon the operating mode and control registers, the external bus may be eight or 16 bits. there are cases where 8-bit and 16-bit accesses ca n appear on adjacent cycles using the lstrb signal to indicate 8-bit or 16-bit data. 6.2 detecting access type from external signals the external signals lstrb , r/w , and a0 can be used to determine the type of bus access that is taking place. accesses to the internal ram module are the only accesses that produce lstrb = a0 = 1, because the internal ram is specifically designed to allow misaligned 16-bit accesses in a single cycle. in these cases, the data for the address that was accessed is on the low half of the data bus and the data for address +1 is on the high half of the data bus (data order is swapped). table 6-1. detecting access type lstrb a0 r/w type of access 1 0 1 8-bit read of an even address 0 1 1 8-bit read of an odd address 1 0 0 8-bit write to an even address 0 1 0 8-bit write to an odd address 0 0 1 16-bit read of an even address 1 1 1 16-bit read of an odd address (low/high data swapped) 0 0 0 16-bit write to an even address 1 1 0 16-bit write to an odd address (low/high data swapped)
bus control and input/output (i/o) data sheet m68hc12b family ? rev. 9.0 88 bus control and input/output (i/o) motorola 6.3 registers under certain conditions, not all registers are visible in the memory map. in special peripheral mode, the first 16 registers associated with bus expansion are removed from the memory map. in expanded modes, some or all of port a, port b, and port e are used for expansion buses and control signals. to allow emulati on of the single-chip functions of these ports, some of these registers must be rebuilt in an external port replacement unit. in any expanded mode, port a and port b are used for address and data lines so registers for these ports, as well as the data direction registers for these ports, are removed from the on-chip memory map and become external accesses. in any expanded mode, port e pins may be needed for bus control (for example, eclk and r/w ). to regain the single-chip functions of port e, the emulate port e (eme) control bit in the mode register may be set. in this special case of expanded mode and eme set, the port e data register (porte) and port e data direction register (ddre) are removed from the on- chip memory map and become external accesses so port e may be rebuilt externally. 6.3.1 port a data register read: anytime, if register is in the map write: anytime, if register is in the map bits pa7?pa0 are associated with addresses addr15?addr8 and data15?data8. when this port is not used for external addresses and data, such as in single-chip mode, these pins can be used as general-purpose input/output (i/o). ddra determines the prim ary direction of each pin. th is register is not in the on-chip map in expanded and peripheral modes. address: $0000 bit 7654321bit 0 read: pa7 pa6 pa5 pa4 pa3 pa2 pa1 pa0 write: reset: unaffected by reset expanded wide and peripheral: addr15 data15 addr14 data14 addr13 data13 addr12 data12 addr11 data11 addr10 data10 addr9 data9 addr8 data8 expanded narrow: addr15 data15/7 addr14 data14/6 addr13 data13/5 addr12 data12/4 addr11 data11/3 addr10 data10/2 addr9 data9/1 addr8 data8/0 figure 6-1. port a data register (porta)
bus control and input/output (i/o) registers m68hc12b family ? rev. 9.0 data sheet motorola bus control and input/output (i/o) 89 6.3.2 port a data direction register read: anytime, if register is in the map write: anytime, if register is in the map this register determines the primary direction for each port a pin when functioning as a general-purpose i/o port. ddra is not in the on-chip map in expanded and peripheral modes. 1 = associated pin is an output. 0 = associated pin is a high-impedance input. 6.3.3 port b data register read: anytime, if register is in the map write: anytime, if register is in the map bits pb7?pb0 are associated with addresses addr7?addr0 and data7?data0. when port b is not used for external addresses and data such as in single-chip mode, thes e pins can be used as general-purpose i/o. ddrb determines the primary direction of each pin. this register is not in the on-chip map in expanded and peripheral modes. address: $0002 bit 7654321bit 0 read: dda7 dda6 dda5 dda4 dda3 dda2 dda1 dda0 write: reset:00000000 figure 6-2. port a data direction register (ddra) address: $0001 bit 7654321bit 0 read: pb7 pb6 pb5 pb4 pb3 pb2 pb1 pb0 write: reset: unaffected by reset alternate functions: expanded wide and peripheral: addr7 data7 addr6 data6 addr5 data5 addr4 data4 addr3 data3 addr2 data2 addr1 data1 addr0 data0 expanded narrow: addr7 addr6 addr5 addr4 addr3 addr2 addr1 addr0 figure 6-3. port b data register (portb)
bus control and input/output (i/o) data sheet m68hc12b family ? rev. 9.0 90 bus control and input/output (i/o) motorola 6.3.4 port b data direction register read: anytime, if register is in the map write: anytime, if register is in the map this register determines the primary direction for each port b pin when functioning as a general-purpose i/o port. ddrb is not in the on-chip map in expanded and peripheral modes. 1 = associated pin is an output. 0 = associated pin is a high-impedance input. 6.3.5 port e data register read: anytime, if register is in the map write: anytime, if register is in the map this register is associated with exter nal bus control signals and interrupt inputs including:  data bus enable (dbe )  mode select (modb/ipipe1 and moda/ipipe0) e clock  data size (lstrb /taglo )  read/write (r/w ) irq xirq address: $0003 bit 7654321bit 0 read: ddb7 ddb6 ddb5 ddb4 ddb3 ddb2 ddb1 ddb0 write: reset:00000000 figure 6-4. port b data direction register (ddrb) address: $0008 bit 7654321bit 0 read: pe7 pe6 pe5 pe4 pe3 pe2 pe1 pe0 write: reset:00000000 alternate function: dbe modb or ipipe1 moda or ipipe0 eclk lstrb or taglo r/w irq xirq figure 6-5. port e data register (porte)
bus control and input/output (i/o) registers m68hc12b family ? rev. 9.0 data sheet motorola bus control and input/output (i/o) 91 when the associated pin is not used for one of these specific functions, the pin can be used as general-purpose i/o. the port e assignment register (pear) selects the function of each pin. ddre determines the primary direction of each port e pin when configured to be general-purpose i/o. some of these pins have so ftware selectable pullups (dbe , lstrb , r/w , and xirq ). a single control bit enables the pul lups for all these pins which are configured as inputs. irq always has a pullup. this register is not in the map in peripheral mode or expanded modes when the eme bit is set. 6.3.6 port e data direction register read: anytime, if register is in the map write: anytime, if register is in the map this register determines the primary direction for each port e pin configured as general-purpose i/o. 1 = associated pin is an output. 0 = associated pin is a high-impedance input. pe1 and pe0 are associated with xirq and irq and cannot be configured as outputs. these pins can be read regardless of whether the alternate interrupt functions are enabled. this register is not in the map in peripheral mode and expanded modes while the eme control bit is set. address: $0009 bit 7654321bit 0 read: dde7 dde6 dde5 dde4 dde3 dde2 00 write: reset:00000000 = unimplemented figure 6-6. port e data direction register (ddre)
bus control and input/output (i/o) data sheet m68hc12b family ? rev. 9.0 92 bus control and input/output (i/o) motorola 6.3.7 port e assignment register read: anytime, if register is in the map write: varies from bit to bit, if register is in the map the pear register is used to choose bet ween the general-purpose i/o functions and the alternate bus control functions of port e. when an alternate control function is selected, the associated ddre bits are overridden. the reset condition of this register depends on the mode of operation because bus-control signals are needed immediately after reset in some modes. in normal single-chip mode , no external bus control signals are needed, so all of port e is configured for general-purpose i/o. in special single-chip mode , the e clock is enabled as a timing reference, and the other bits of port e are configured for general-purpose i/o. in normal expanded modes , the reset vector is located in external memory. the e clock may be required for this access but r/w is only needed by the system when there are external writable resources. therefore, in normal expanded modes, only the e clock is configured for its alternate bus control function and the other bits of port e are configured for general-purpose i/o. if the normal expanded system needs any other bus-control signals, pear would need to be written before any access that needed the additional signals. in special expanded modes , ipipe1, ipipe0, e, r/w , and lstrb are configured as bus-control signals. in peripheral mode , the pear register is not acce ssible for reads or writes. address: $000a bit 7654321bit 0 read: ndbe cgmte pipoe neclk lstre rdwe 00 write: reset states: normal single-chip:10010000 special single-chip:00101100 normal expanded: 00000000 special expanded: 00101100 peripheral:11010000 = unimplemented figure 6-7. port e assignment register (pear)
bus control and input/output (i/o) registers m68hc12b family ? rev. 9.0 data sheet motorola bus control and input/output (i/o) 93 ndbe ? no data bus enable bit normal: write once special: write anytime except the first time 1 = pe7 used for general-purpose i/o 0 = pe7 used for external control of data enables on memories cgmte ? cgm test output enable normal: write once special: write anytime except the first time. this bit is read at anytime. 1 = pe6 is a test signal output from the cgm module (no effect in single chip or normal expanded modes). pipoe = 1 overrides this function and forces pe6 to be a pipe status output signal. 0 = pe6 is a general-purpose i/o or pipe output. pipoe ? pipe signal output enable bit normal: write once special: write anytime except the first time. this bit has no effect in single chip modes. 1 = pe6?pe5 are outputs and indicate state of instruction queue. 0 = pe6?pe5 are general-purpose i/o. neclk ? no external e clock bit in expanded modes, writes to this bit ha ve no effect. e clock is required for demultiplexing the external address; neclk remains 0 in expanded modes. neclk can be written once in normal single-chip mode and can be written anytime in special single-chip mode. 1 = pe4 is a general-purpose i/o pin. 0 = pe4 is the external e clock pin subj ect to this limitation: in single-chip modes, pe4 is general-purpose i/o unless neclk = 0 and either ivis = 1 or estr = 0. a 16-bit write to pear:mode can configure all three bits in one operation. lstre ? low strobe (lstrb ) enable bit normal: write once special: write anytime except the first time this bit has no effect in single-chip modes or normal expanded narrow mode. 1 = pe3 is configured as the lstrb bus-control output. 0 = pe3 is a general-purpose i/o pin. lstrb is used during external writes. a fter reset in normal expanded mode, lstrb is disabled. if needed, it should be enabled before external writes. external reads do not normally need lstrb because all 16 data bits can be driven even if the mcu only needs eight bits of data. tag l o is a shared function of the pe3/lstrb pin. in special expanded modes with lstre set and the bdm instruction tagging on, a 0 at the falling edge of e tags the instruction word low byte being read into the instruction queue.
bus control and input/output (i/o) data sheet m68hc12b family ? rev. 9.0 94 bus control and input/output (i/o) motorola rdwe ? read/write enable bit normal: write once special: write anytime except the first time this bit has no effect in single-chip modes. 1 = pe2 configured as r/w pin 0 = pe2 configured as general-purpose i/o pin r/w is used for external writes. after reset in normal expanded mode, it is disabled. if needed, it should be enabled before any external writes. 6.3.8 pullup control register read: anytime, if register is in the map write: anytime, if register is in the map these bits select pullup resistors for any pin in the corresponding port that is currently configured as an input. this register is not in the map in peripheral mode. pupe ? pullup port e enable bit pin pe1 always has a pullup. pins pe6, pe5, and pe4 never have pullups. 1 = enable port e pullups on pe7, pe3, pe2, pe1, and pe0 0 = disable port e pullups on pe7, pe3, pe2, pe1, and pe0 pupb ? pullup port b enable bit 1 = enable pullups for all port b input pins 0 = disable port b pullups this bit has no effect if port b is used as part of the address/data bus (pullups are inactive). pupa ? pullup port a enable bit 0 = disable port a pullups 1 = enable pullups for all port a input pins this bit has no effect, if port a is used as part of the address/data bus (pullups are inactive). address: $000c bit 7654321bit 0 read: 0 0 0 pupe 00 pupb pupa write: reset:00010000 = unimplemented figure 6-8. pullup control register (pucr)
bus control and input/output (i/o) registers m68hc12b family ? rev. 9.0 data sheet motorola bus control and input/output (i/o) 95 6.3.9 reduced drive of i/o lines read: anytime, if register is in the map write: once in normal modes; anytime, except the first time, in special modes these bits select reduced drive for the associated port pins. this gives reduced power consumption and reduced radio frequ ency interference (rfi) with a slight increase in transition time (depending on loading). the reduced drive function is independent of which function is being used on a particular port. this register is not in the map in peripheral mode. rdpe ? reduced drive of port e bit 1 = reduced drive for all port e output pins 0 = full drive for all port e output pins rdpb ? reduced drive of port b bit 1 = reduced drive for all port b output pins 0 = full drive for all port b output pins rdpa ? reduced drive of port a bit 1 = reduced drive for all port a output pins 0 = full drive for all port a output pins address: $000d bit 7654321bit 0 read:0000 rdpe 0 rdpb rdpa write: reset:00000000 = unimplemented figure 6-9. reduced drive of i/o lines (rdriv)
bus control and input/output (i/o) data sheet m68hc12b family ? rev. 9.0 96 bus control and input/output (i/o) motorola
m68hc12b family ? rev. 9.0 data sheet motorola eeprom 97 data sheet ? m68hc12b family section 7. eeprom 7.1 introduction the mcu is electrically erasable, pr ogrammable read-only memory (eeprom) serves as a 768-byte non-volatile memory which can be used for frequently accessed static data or as fast access program code. the mcu?s eeprom is arranged in a 16 -bit configuration. the eeprom array may be read as either bytes, aligned word s, or misaligned words. access time is one bus cycle for byte and aligned word access and two bus cycles for misaligned word operations. programming is by byte or aligned word. attempts to program or erase misaligned words will fail. only the lower byte w ill be latched and programmed or erased. programming and erasing of the user eeprom can be done in all operating modes. each eeprom byte or aligned word mu st be erased before programming. the eeprom module supports byte , aligned word, row (32 by tes), or bulk erase, all using the internal charge pump. bulk eras ure of odd and even rows is also possible in test modes; the erased state is $ff. the eeprom module has hardware interlocks which protect stored data from corruption by accidentally enabling the program/erase voltage. programming voltage is derived from the internal v dd supply with an internal charge pump. t he eeprom has a minimum program/erase life of 10,000 cycles over the complete operating temperature range. 7.2 eeprom progr ammer?s model the eeprom module consists of two separat ely addressable sections. the first is a 4-byte memory mapped control register block used for control, testing, and configuration of the eepro m array. the second sect ion is the eeprom array itself. at reset, the 4-byte register section starts at address $00f0 and the eeprom array is located from addresses $0d00 to $0fff (see figure 7-1 ). for information on remapping the register block and eeprom address space, refer to section 5. operating modes and resource mapping .
eeprom data sheet m68hc12b family ? rev. 9.0 98 eeprom motorola read access to the memory array section can be enabled or disabled by the eeon control bit in the eeprom initialization register (initee). this feature allows the access of memory mapped resources that have lower priority than the eeprom memory array. eeprom control re gisters can be accessed and eeprom locations may be programmed or erased regardless of the state of eeon. using the normal eeprog control, it is possible to continue program/erase operations during wait. for lowest power consumption during wait, stop program/erase by turning off eepgm. if the stop mode is entered during programming or erasing, program/erase voltage will be turned off automatically and the resistor-capacitor (rc) clock (if enabled) is stopped. however, the eepgm control bit will remain set. when stop mode is terminated, the program/erase voltage will be turned back on automatically if eepgm is set. at bus frequencies below 1 mhz, the rc clock must be turned on for program/erase. figure 7-1. eeprom block protect mapping bprot0 bprot1 bprot2 bprot3 bprot4 $_f00 $_e00 $_d00 $_f80 $_fc0 256 bytes 256 bytes 128 bytes
eeprom eeprom control registers m68hc12b family ? rev. 9.0 data sheet motorola eeprom 99 7.3 eeprom control registers this section describes t he eeprom control registers. 7.3.1 eeprom module configuration register eeswai ? eeprom stops in wait mode bit 0 = module is not affected during wait mode. 1 = module ceases to be clocked during wait mode. this bit should be cleared if the wait mode vectors are mapped in the eeprom array. protlck ? block protect write lock bit 0 = block protect bits and bulk er ase protection bit can be written. 1 = block protect bits are locked. read anytime. write once in normal modes (smodn = 1); set and clear anytime in special modes (smodn = 0). eerc ? eeprom charge pump clock bit 0 = system clock is used as clock source for the internal charge pump. internal rc oscillator is stopped. 1 = internal rc oscillator drives the charge pump. the rc oscillator is required when the system bus clock is lower than f prog . read and write anytime. address: $00f0 bit 7654321bit 0 read: 1 1 1 1 1 eeswai protlck eerc write: reset:11111100 figure 7-2. eeprom module configuration register (eemcr)
eeprom data sheet m68hc12b family ? rev. 9.0 100 eeprom motorola 7.3.2 eeprom block protect register the eeprom block protect register (eep rot) prevents accidental writes to eeprom. read anytime. write anytime if eepgm = 0 and protlck = 0. bprot4?bprot0 ? eeprom block protection bit 0 = associated eeprom block c an be programmed and erased. 1 = associated eeprom block is prot ected from being programmed and erased. cannot be modified while programming is taking place (eepgm = 1). address: $00f1 bit 7654321bit 0 read: 1 1 1 brprot4 brprot3 brprot2 brprot1 brprot0 write: reset:11111111 figure 7-3. eeprom block protect register (eeprot) table 7-1. 768-byte eeprom block protection bit name block protected block size bprot4 $0d00 to $0dff 256 bytes bprot3 $0e00 to $0eff 256 bytes bprot2 $0f00 to $0f7f 128 bytes bprot1 $0f80 to $0fbf 64 bytes bprot0 $0fc0 to $0fff 64 bytes
eeprom eeprom control registers m68hc12b family ? rev. 9.0 data sheet motorola eeprom 101 7.3.3 eeprom test register read anytime. write in special modes only (smodn = 0). these bits are used for test purposes only. in normal modes, the bits are forced to 0. eeodd ? odd row programming bit 0 = odd row bulk programming/erasing is disabled. 1 = bulk program/erase all odd rows. refers to a physical location in the array rather than an odd byte address eeven ? even row programming bit 0 = even row bulk progra mming/erasing is disabled. 1 = bulk program/erase all even rows. refers to a physical location in the array rather than an even byte address. marg ? program and erase voltage margin test enable bit 0 = normal operation 1 = program and erase margin test this bit is used to evaluate the program/erase voltage margin. eecpd ? charge pump disable bit 0 = charge pump is turned on during program/erase. 1 = disable charge pump. eecprd ? charge pump ramp disable bit 0 = charge pump is turned on progressively during program/erase. 1 = disable charge pump controlled ramp up. known to enhance write/eras e endurance of eeprom cells. eecpm ? charge pump monitor enable bit 0 = normal operation 1 = output the charge pump voltage on the irq /v pp pin. address: $00f2 bit 7654321bit 0 read: eeodd eeven marg eecpd eecprd 0 eecpm 0 write: reset:00000000 figure 7-4. eeprom test register (eetst)
eeprom data sheet m68hc12b family ? rev. 9.0 102 eeprom motorola 7.3.4 eeprom control register bulkp ? bulk erase protection bit 0 = eeprom can be bulk erased. 1 = eeprom is protected from being bulk or row erased. read anytime. write anytime if eepgm = 0 and protlck = 0. byte ? byte and aligned word erase bit 0 = bulk or row erase is enabled. 1 = one byte or one aligned word erase only read anytime. write anytime if eepgm = 0. row ? row or bulk erase bit (when byte = 0) 0 = erase entire eeprom array. 1 = erase only one 32-byte row. read anytime. write anytime if eepgm = 0. byte and row have no effect when erase = 0. if byte = 1 and test mode is not enabled, only the location specified by the address written to the programming latches will be erased. the operation will be a byte or an aligned word erase depending on the size of written data. erase ? erase control bit 0 = eeprom configuration for programming or reading 1 = eeprom configuration for erasure read anytime. write anytime if eepgm = 0. configures the eeprom for erasure or programming. when test mode is not enabled and unless bulkp is set, erasure is by byte, aligned word, row, or bulk. address: $00f3 bit 7654321bit 0 read: bulkp 0 0 byte row erase eelat eepgm write: reset:10000000 figure 7-5. eeprom control register (eeprog) table 7-2. erase selection byte row block size 0 0 bulk erase entire eeprom array 0 1 row erase 32 bytes 1 0 byte or aligned word erase 1 1 byte or aligned word erase
eeprom eeprom control registers m68hc12b family ? rev. 9.0 data sheet motorola eeprom 103 eelat ? eeprom latch control bit 0 = eeprom set up for normal reads 1 = eeprom address and data bus latches set up for programming or erasing read anytime. write anytime if eepgm = 0. note: when eelat is set, the entire eeprom is unavailable for reads. therefore, no program residing in the eeprom can be executed while attempting to program unused eeprom space. care should be taken that no refere nces to the eeprom are used while programming. interrupts should be turned off if the vectors are in the eeprom. timing and any serial co mmunications must be done with polling during the programming process. byte, row, erase, and eelat bits can be written simultaneously or in any sequence. eepgm ? program and erase enable bit 0 = disables program/erase voltage to eeprom 1 = applies program/erase voltage to eeprom the eepgm bit can be set only after eel at has been set. when an attempt is made to set eelat and eepgm simult aneously, eepgm remains clear but eelat is set. the bulkp, byte, row, erase, and eelat bits cannot be changed when eepgm is set. to complete a program or erase, a write to clear eepgm and eelat bits is required before reading the programmed data. a write to an eeprom location has no e ffect when eepgm is se t. latched address and data cannot be modified during program or erase. a program or erase operation should follow this sequence: 1. write byte, row, and erase to the desired value; write eelat = 1. 2. write a byte or an aligned word to an eeprom address. 3. write eepgm = 1. 4. wait for programming ( t prog ) or erase ( t erase ) delay time. 5. write eepgm = 0 and eelat = 0. to program/erase more bytes or words without intermediate eeprom reads, only write eepgm = 0 in step 5, leaving eelat = 1, and jump to step 2.
eeprom data sheet m68hc12b family ? rev. 9.0 104 eeprom motorola
m68hc12b family ? rev. 9.0 data sheet motorola flash eeprom 105 data sheet ? m68hc12b family section 8. flash eeprom 8.1 introduction the 32-kbyte flash eeprom modul e for the mc68hc912b32 and mc68hc912bc32 serves as electrically erasable and programmable, non-volatile rom emulation memory. the module can be used for program code that must either execute at high speed or is frequent ly executed, such as operating system kernels and standard subroutines, or it can be used for static data which is read frequently. the flash eeprom is ideal for program storage for single-chip applications allowing for field reprogramming. note: the mc68hc12be32 and mc68hc12bc32 does not contain flash eeprom. the flash eeprom array is arranged in a 16-bit configuration and may be read as either bytes, aligned words or misaligned words. access time is one bus cycle for byte and aligned word access and two bus cycles for misaligned word operations. the flash eeprom module requires an external program/erase voltage (v fp ) to program or erase the flash eeprom arra y. the external program/erase voltage is provided to the flash ee prom module via an external v fp pin. to prevent damage to the flash array, v fp should always be greater than or equal to v dd ?0.35 v. programming is by byte or aligned word. the flash eeprom module supports bulk erase only. the flash eeprom module has hardware interlocks which protect stored data from accidental corruption. an erase- and program-protected 2-kbyte block for boot routines is located at $7800?$7fff or $f800?$ffff, depending upon the mapped location of the flash eeprom array. (the protected boot block on the initial mask sets, g86w and g75r, is 1-kbyte and is located at $7c00?$7fff or $fc00?$ffff.) 8.2 flash eeprom array after reset, the flash eeprom array is located from addresses $8000 to $ffff in single-chip mode. in expanded modes, the flash eeprom array is located from address $0000 to $7fff; however, it is disabled from the memory map. the flash eeprom can be mapped to an alternate address range. see section 5. operating modes and resource mapping .
flash eeprom data sheet m68hc12b family ? rev. 9.0 106 flash eeprom motorola 8.3 flash eeprom registers a 4-byte register block controls the flash eeprom module operation. configuration information is specified and programmed independently from the contents of the flash eeprom array. at re set, the 4-byte register section starts at address $00f4. 8.3.1 flash eeprom lock control register in normal modes, the lock bit can be written only once after reset. lock ? lock register bit 0 = enable write to feemcr register. 1 = disable write to feemcr register. 8.3.2 flash eeprom module configuration register this register controls the operation of the flash eeprom array. bootp cannot be changed when the lock control bit in the feelck register is set or if enpe in the feectl register is set. the boot block is located at $7800?$7fff or $f800?$ffff, depending upon the mapped location of the flash eeprom array and mask set ($7c00?$7fff or $fc00?$ffff for 1-kbyte block). bootp ? boot protect bit 0 = enable erase and program of 1-kbyte or 2-kbyte boot block. 1 = disable erase and program of 1-kbyte or 2-kbyte boot block. address: $00f4 bit 7654321bit 0 read: 0000000lock write: reset:00000000 figure 8-1. flash eeprom lock control register (feelck) address: $00f5 bit 7654321bit 0 read: 0000000bootp write: reset:00000001 figure 8-2. flash eeprom module configuration register (feemcr)
flash eeprom flash eeprom registers m68hc12b family ? rev. 9.0 data sheet motorola flash eeprom 107 8.3.3 flash eeprom module test register in normal mode, writes to feetst control bits have no effect and always read 0. the flash eeprom module cannot be plac ed in test mode inadvertently during normal operation. fste ? stress test enable bit 0 = disables the gate/drain stress circuitry 1 = enables the gate/drain stress circuitry gadr ? gate/drain stress test select bit 0 = selects the drain stress circuitry 1 = selects the gate stress circuitry hvt ? stress test high voltage status bit 0 = high voltage not present during stress test 1 = high voltage present during stress test fenlv ? enable low voltage bit 0 = disables low voltage transistor in current reference circuit 1 = enables low voltage transistor in current reference circuit fdisvfp ? disable status v fp voltage lock bit when the v fp pin is below normal programming voltage, the flash module will not allow writing to the lat bit; the user cannot erase or program the flash module. the fdisvfp control bit enables writing to the lat bit regardless of the voltage on the v fp pin. 0 = enable the automatic lock mechanism if v fp is low. 1 = disable the automatic lock mechanism if v fp is low. vtck ? v t check test enable bit when vtck is set, the flash eeprom module uses the v fp pin to control the control gate voltage; the sense amp timeout path is disabled. this allows for indirect measurements of the bit cells? program and erase threshold. if v fp < v zbrk (breakdown voltage), the control gate will equal the v fp voltage. if v fp > v zbrk , the control gate will be regulated by this equation: control gate voltage = v zbrk + 0.44 (v fp ? v zbrk ) 0 = v t test disable 1 = v t test enable address: $00f6 bit 7654321bit 0 read: fste gadr hvt fenlv fdisvfp vtck stre mwpr write: reset:00000000 figure 8-3. flash eeprom module test register (feetst)
flash eeprom data sheet m68hc12b family ? rev. 9.0 108 flash eeprom motorola stre ? spare test row enable bit the spare test row consists of one flash eeprom array row. the spare test row is reserved and contains production test information which must be maintained through several erase cycles . when stre is set, the decoding for the spare test row overrides the address lines which normally select the other rows in the array. 0 = lib accesses are to the flash eeprom array. 1 = spare test row in array enabled if smod is active mwpr ? multiple word programming bit used primarily for testing, if mpwr = 1, the two least significant address lines, addr1 and addr0, will be ignored when programming a flash eeprom location. the word location addressed if addr1 and addr0 = 00, along with the word location addressed if addr1 and addr0 = 10, will both be programmed with the same word data fr om the programming latches. this bit should not be changed during programming. 0 = multiple word programming disabled 1 = program 32 bits of data 8.3.4 flash eeprom control register this register controls the program ming and erasure of the flash eeprom. feeswai ? flash eeprom stop in wait control bit 0 = do not halt flash eeprom clock when in wait mode. 1 = halt flash eeprom clock when in wait mode. note: the feeswai bit cannot be asserted if the interrupt vector resides in the flash eeprom array. svfp ? status v fp voltage bit svfp is a read-only bit. 0 = voltage of v fp pin is below normal programming voltage levels. 1 = voltage of v fp pin is above normal programming voltage levels. eras ? erase control bit this bit can be read anytime or written when enpe = 0. when set, all locations in the array will be erased at the same time. the boot block will be erased only if bootp = 0. this bit also affects th e result of attempted array reads. see table 8-1 for more information. status of eras cannot change if enpe is set. 0 = flash eeprom configured for programming 1 = flash eeprom configured for erasure address: $00f7 bit 7654321bit 0 read: 0 0 0 feeswai svfp eras lat enpe write: reset:00000000 figure 8-4. flash eeprom control register (feectl)
flash eeprom operation m68hc12b family ? rev. 9.0 data sheet motorola flash eeprom 109 lat ? latch control bit this bit can be read anytime or written when enpe = 0. when set, the flash eeprom is configured for programming or erasure and, upon the next valid write to the array, the address and data will be latched for the programming sequence. see table 8-1 for the effects of lat on array reads. a high voltage detect circuit on the v fp pin will prevent assertion of the lat bit when the programming voltage is at normal levels. 0 = programming latches disabled 1 = programming latches enabled enpe ? enable programming/erase bit 0 = disables program/erase voltage to flash eeprom 1 = applies program/erase voltage to flash eeprom enpe can be asserted only after lat has been asserted and a write to the data and address latches has occurred. if an attempt is made to assert enpe when lat is negated, or if the latches have not been written to after lat was asserted, enpe will remain negated a fter the write cycle is complete. the lat, eras, and bootp bits cannot be changed when enpe is asserted. a write to feectl may affect only the state of enpe. attempts to read a flash eeprom array location in the fl ash eeprom module while enpe is asserted will not return the data addressed. see table 8-1 for more information. flash eeprom module control registers may be read or written while enpe is asserted. if enpe is asserted and lat is negated on the same write access, no programming or erasure will be performed. 8.4 operation the flash eeprom can contain program an d data. on reset, it can operate as a bootstrap memory to provide the cpu with internal initialization information during the reset sequence. 8.4.1 bootstrap operation single-chip mode after reset, the cpu controlling the system will begin booting up by fetching the first program address from address $fffe. table 8-1. effects of enpe, lat, and eras on array reads enpe lat eras result of read 0 0 ? normal read of location addressed 0 1 0 read of location being programmed 0 1 1 normal read of location addressed 1 ? ? read cycle is ignored
flash eeprom data sheet m68hc12b family ? rev. 9.0 110 flash eeprom motorola 8.4.2 normal operation the flash eeprom allows a byte or ali gned word read/write in one bus cycle. misaligned word read/write require an a dditional bus cycle. the flash eeprom array responds to read operations only. write operations are ignored. 8.4.3 program/erase operation an unprogrammed flash eeprom bit has a logic state of 1. a bit must be programmed to change its state from 1 to 0. erasing a bit returns it to a logic 1. the flash eeprom has a minimum program/era se life of 100 cycles. programming or erasing the flash eeprom is accompli shed by a series of control register writes and a write to a set of programming latches. programming is restricted to a single byte or aligned word at a time determined by internal signals sz8 and ad dr0. the flash eeprom must first be completely erased prior to programming final data values . it is possible to program a location in the flash eeprom without erasing the entire array, if the new value does not require the changing of bit values from 0 to 1. 8.4.3.1 read/write accesses during program/erase during program or erase operations, read and write accesses may be different from those during normal operation and are a ffected by the state of the control bits in the flash eeprom control register (feectl). the next write to any valid address to the array after lat is set will cause the address and data to be latched into the programming latches. once the address and data are latched, write accesses to the array will be ignored while lat is set. writes to the control registers will occur normally. 8.4.3.2 program/erase verification when programming or erasi ng the flash eeprom array, a special verification method is required to ensure that the program/erase process is reliable and also to provide the longest possible life expectancy. this method requires stopping the program/erase sequence at periods of t ppulse (t epulse for erasing) to determine if the flash eeprom is programmed/er ased. after the location reaches the proper value, it must continue to be pr ogrammed/erased with additional margin pulses to ensure that it will remain programmed/erased. failure to provide the margin pulses could lead to corrupted or unreliable data. 8.4.3.3 program/erase sequence to begin a program or erase sequence, the external v fp voltage must be applied and stabilized. the eras bit must be set or cleared, depending on whether a program sequence or an erase sequence is to occur. the lat bit will be set to cause any subsequent data written to a va lid address within the flash eeprom to be latched into the programming address and data latches. the next flash
flash eeprom operation m68hc12b family ? rev. 9.0 data sheet motorola flash eeprom 111 array write cycle must be either to the location that is to be programmed if a programming sequence is being performed, or, if erasing, to any valid flash eeprom array location. writing the new address and data information to the flash eeprom is followed by assertion of enpe to turn on the program/erase voltage to program/erase the new location(s). the lat bit must be asserted and the address and data latched to allow the setting of the enpe control bit. if the data and address have not been latched, an attempt to assert enpe will be ignored and enpe will remain negated after the write cycle to feectl is completed. the lat bit must remain asserted and the eras bit must remain in its current state as long as enpe is asserted. a write to the lat bit to clear it while enpe is set will be ignored. that is, after the write cycle, lat will remain asserted. likewise, an attempt to change the state of eras will be ignored and the state of the eras bit will remain unchanged. the programming software is responsible for all timing during a program sequence. this includes the total number of program pulses (n pp ), the length of the program pulse (t ppulse ), the program margin pulses (p m ) and the delay between turning off the high voltage and verifying the operation (t vprog ). the erase software is responsible for al l timing during an erase sequence. this includes the total number of erase pulses (e m ), the length of the erase pulse (t epulse ), the erase margin pulse or pulses, and the delay between turning off the high voltage and verifying the operation (t verase ). software also controls the supply of the proper program/erase voltage to the v fp pin and should be at the proper level before enpe is set during a program/erase sequence. a program/erase cycle should not be in progress when starting another program/erase or while attempting to read from the array. note: although clearing enpe disables the program/erase voltage (v fp ) from the v fp pin to the array, care must be taken to ensure that v fp is at v dd whenever programming/erasing is not in progres s. not doing so could damage the part. ensuring that v fp is always greater or equal to v dd can be accomplished by controlling the v fp power supply with the progra mming software via an output pin. alternatively, all programming and erasing can be done prior to installing the device on an application circuit boar d which can always connect v fp to v dd . programming can also be accomplished by plugging the board into a special programming fixture which provides program/erase voltage to the v fp pin.
flash eeprom data sheet m68hc12b family ? rev. 9.0 112 flash eeprom motorola 8.5 programming the flash eeprom programming the flash eeprom is accomplished by this step-by-step procedure. the v fp pin voltage must be at the proper level prior to executing step 4 the first time. 1. apply program/erase voltage to the v fp pin. 2. clear eras and set the lat bit in the feectl register to establish program mode and enable programming address and data latches. 3. write data to a valid address. the address and data are latched. if bootp is asserted, an attempt to program an address in the boot block will be ignored. 4. apply programming voltage by setting enpe. 5. delay for one programming pulse, t ppulse . 6. remove programming voltage by clearing enpe. 7. delay while high voltage is turning off, t vprog . 8. read the address location to verify that it has been programmed, 9. if the location is not programmed, repeat steps 4 through 7 until the location is programmed or until the specifie d maximum number of program pulses, n pp , has been reached. 10. if the location is programmed, repeat the same number of pulses as required to program the location. this provides 100 percent program margin. 11. read the address location to verify that it remains programmed. 12. clear lat. 13. if there are more locations to program, repeat steps 2 through 10. 14. turn off v fp . reduce voltage on v fp pin to v dd . the flowchart in figure 8-5 demonstrates the recommended programming sequence.
flash eeprom programming the flash eeprom m68hc12b family ? rev. 9.0 data sheet motorola flash eeprom 113 figure 8-5. program sequence flow start prog set lat clear eras write data to address set enpe read get next address/data no location failed location clear margin flag increment n pp counter no decrement n pp counter no yes yes yes to program turn on v fp delay for duration of program pulse (t ppulse ) clear enpe delay before verify is margin flag set? no yes no yes data correct? set margin flag data correct? n pp = 0? done? turn off v fp (t vprog ) n pp = 50? yes no done prog clear program pulse counter (n pp ) clear lat
flash eeprom data sheet m68hc12b family ? rev. 9.0 114 flash eeprom motorola 8.6 erasing the flash eeprom this sequence demonstrates the recommended procedure for erasing the flash eeprom. the v fp pin voltage must be at the proper level prior to executing step 4 the first time. 1. turn on v fp . apply program/erase voltage to the v fp pin. 2. set the lat bit and eras bit to c onfigure the flash eeprom for erasing. 3. write to any valid address in the flash array. this allows the erase voltage to be turned on; the data written and the address written are not important. the boot block will be erased only if the control bit bootp is negated. 4. apply erase voltage by setting enpe. 5. delay for a single erase pulse, t epulse . 6. remove erase voltage by clearing enpe. 7. delay while high voltage is turning off, t verase . 8. read the entire array to ensure that the flash eeprom is erased. 9. if all of the flash eeprom locati ons are not erased, repeat steps 4 through 7 until either the remaining locations are erased or until the maximum erase pulses have been applied, n ep . 10. if all of the flash eeprom locations are erased, repeat the same number of pulses as required to erase the a rray. this provides 100 percent erase margin. 11. read the entire array to ensure that the flash eeprom is erased. 12. clear lat. 13. turn off v fp . reduce voltage on v fp pin to v dd . the flowchart in figure 8-6 demonstrates the recommended erase sequence.
flash eeprom erasing the flash eeprom m68hc12b family ? rev. 9.0 data sheet motorola flash eeprom 115 figure 8-6. erase sequence flow start erase set lat set eras write to array set enpe read no array failed to erase array clear margin flag increment n ep counter decrement n ep counter no yes yes turn on v fp delay for duration of erase pulse (t epulse ) clear enpe delay before verify is margin flag set? no yes no yes array erased? set margin flag n ep = 0? turn off v fp (t verase ) n ep = 5? yes no array erased clear erase pulse counter (n ep ) clear lat array erased?
flash eeprom data sheet m68hc12b family ? rev. 9.0 116 flash eeprom motorola 8.7 program/erase pr otection interlocks the flash eeprom program and erase mechanisms provide maximum protection from accidental programming or erasure. the voltage required to program/erase the flash eeprom (v fp ) is supplied via an external pin. if v fp is not present, no progra mming/erasing will occur. furthermore, the program/erase voltage will not be applied to the flash eeprom unless turned on by setting a cont rol bit (enpe). the enpe bit may not be set unless the programming address and data latches have been written previously with a valid address. the latches may not be written unless enabled by setting a control bit (lat). the lat and enpe control bits must be written on separate writes to the control register (feectl) and must be separated by a write to the programming latches. the eras and lat bits are also protected when enpe is set. this prevents inadvertent switching between erase/program mode and also prevents the latched data and address from being changed after a program cycle has been initiated. 8.8 stop or wait mode when stop or wait commands are executed, the mcu puts the flash eeprom in stop or wait mode. in thes e modes, the flash module will cease erasure or programming immediately. note: it is advised to not enter stop or wait modes when programming the flash array. the flash eeprom module is not able to recover from stop mode without a 250-ns delay. if the operating bus frequency is greater than 4 mhz, the dly bit must be set to1 to use the flash after recovering from stop mode. other options are to map the eeprom modul e over the flash module in the memory map with dly = 0 and place the interrupt vectors in the eeprom array or use reset to recover from a stop mode executed from flash eeprom. recovery from a stop instruction executed from eeprom and ram operates normally. 8.9 test mode the flash eeprom has some special test functions which are only accessible when the device is in test mode. test mode is indicate d to the flash eeprom module when the smod line on the lib is asserted. when smod is asserted, the special test control bits may be accessed via the lib to invoke the special test functions in the flash eeprom module. wh en smod is not asserted, writes to the test control bits have no effect and al l bits in the test register feetst will be cleared. this ensures that flash eeprom test mode cannot be invoked inadvertently during normal operation. the flash eeprom module will operate nor mally, even if smod is asserted, until a special test function is invoked. the test mode adds additional features over normal mode. these features allow the tests to be performed even after the device is installed in the final product.
m68hc12b family ? rev. 9.0 data sheet motorola read-only memory (rom) 117 data sheet ? m68hc12b family section 9. read-only memory (rom) 9.1 introduction the mc68hc12be32 and mc68hc12bc32 contain 32 kbytes of read-only memory (rom). the rom array is arranged in a 16-bit configuration and may be read as either bytes, aligned words or misaligned words. access time is one bus cycle for byte and aligned word access and two bus cycles for misaligned word operations. 9.2 rom array after reset, the rom array is located from addresses $8000 to $ffff in single-chip mode. in expanded modes, the rom array is located from address $0000 to $7fff; however, it is disabled from the memory map. the rom can be mapped to an alternate address range. see section 5. operating modes and resource mapping .
read-only memory (rom) data sheet m68hc12b family ? rev. 9.0 118 read-only memory (rom) motorola
m68hc12b family ? rev. 9.0 data sheet motorola clock generation module (cgm) 119 data sheet ? m68hc12b family section 10. clock generation module (cgm) 10.1 introduction the clock generation module (cgm) generates the system clocks and generates and controls the timing of the reset and power-on reset (por) logic. the cgm is composed of:  clock selection and generation circuitry  slow-mode clock divider  reset and stop generation timing and control note: older device mask sets do not support the slow-mode clock divider feature. register $00e0 is reserved in ol der devices and provides no function. mask sets that do not have the slow -mode clock divider feature on the mc68hc912b32 include: g96p, g86w, and h91f. mask sets that do not have the slow -mode clock divider feature on the mc68hc12be32 include: h54t and j38m. mask sets that do not have the slow -mode clock divider feature on the mc68hc(9)12bc32 include: j15g. 10.2 block diagram figure 10-1. cgm block diagram extal xtal e clock p clock t clock reduced consumption oscillator t clock generator to cpu slow mode clock divider wait slow e clock oscillator 2 e and p clock generator to bdlc and tim e clock (gbt) p clock (gbt) to buses, bdm, spi, sci, atd, rti, cop, pwm, fee, ee, ram slow p clock out
clock generation module (cgm) data sheet m68hc12b family ? rev. 9.0 120 clock generation module (cgm) motorola 10.3 register map 10.4 clock selectio n and generation the cgm generates the p clock, the e clock, and four t clocks. the p clock and e clock are used by all device modules ex cept the cpu. the t clocks are used by the cpu. figure 10-3 shows clock timing relationships while in normal run modes. there are two types of p clocks and e clocks while in wait mode:  global type (g), which is driven by t he slow clock divider in wait mode and drives all on-chip peripherals except the bdlc and the timer  global type (gbt), which remains at the oscillator divide-by-2 rate in wait mode and drives the bdlc and the timer figure 10-4 shows clock timing relationships while in wait mode. addr. register name bit 7654321bit 0 $0014 real-time interrupt control register (rtictl) see page 124. read: rtie rswai rsbck 0 rtbyp rtr2 rtr1 rtr0 write: reset:00000000 $0015 real-time interrupt flag register (rtiflg) see page 125. read: rtif0000000 write: reset:00000000 $0016 cop control register (copctl) see page 125. read: cme fcme fcm fcop disr cr2 cr1 cr0 write: reset:00000001 $0017 arm/reset cop timer register (coprst) see page 127. read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 $00e0 slow mode divider register (slow) see page 123. read: 0 0 0 0 0 sldv2 sldv1 sldv0 write: reset:00000000 = unimplemented figure 10-2. cgm register map
clock generation module (cgm) clock selection and generation m68hc12b family ? rev. 9.0 data sheet motorola clock generation module (cgm) 121 figure 10-3. internal clock relationships in normal run modes figure 10-4. internal clock relationships in wait mode t1 clock t2 clock t3 clock t4 clock e clock p clock oscillator e clock p clock oscillator t1 clock t2 clock t3 clock t4 clock e clock p clock 1. driven by slow clock divider in wait mode. drives on-chip per ipherals except bdlc and timer. 2. remains at oscillator divided by 2 ra te in wait mode. drives bdlc and timer. notes: (g) (1) (g) (1) (gbt) (2) (gbt) (2)
clock generation module (cgm) data sheet m68hc12b family ? rev. 9.0 122 clock generation module (cgm) motorola 10.5 slow mode divider the slow mode divider is included to del iver a variable bus frequency to the mcu in wait mode. the bus clocks are derived fr om the constant p clock. the slow clock counter divides the p clock and e clock fr equency in powers of 2, up to 128. when the slow control register is cleared or t he part is not in wait mode, the slow mode divider is off and the bus cl ock?s frequency is not changed. note: the clock monitor is clocked by the system clock (oscillator) reference; the slow mode divider allows operation of the mcu at clock periods longer than the clock monitor trigger time. 10.6 clock functions the cgm generates and controls the timing of the reset and por logic. 10.6.1 computer operating properly (cop) the computer operating properly (cop) or watchdog timer is an added check that a program is running and sequencing pr operly. when the cop is being used, software is responsible for keeping a fr ee-running watchdog timer from timing out. if the watchdog timer times out, it is an indication that the software is no longer being executed in the intended sequence; thus, a system reset is initiated. three control bits allow selection of seven cop timeout periods or cop disable. when cop is enabled, sometime during the selected period the program must write $55 and $aa (in this order) to the arm/reset cop register (coprst). if the program fails to do this, the part resets. if any value other than $55 or $aa is written to coprst, the part is reset. 10.6.2 real-time interrupt there is a real-time (periodic) interrupt av ailable to the user. this interrupt occurs at one of seven selected rates. an interrupt flag and an interrupt enable bit are associated with this function. there are three bits for the rate select. 10.6.3 clock monitor the clock monitor circuit is based on an inte rnal resistor-capacitor (rc) time delay. if no mcu clock edges are detected within this rc time delay, the clock monitor can optionally generate a system reset. the clock monitor function is enabled/disabled by the cme control bit in the cop control register (copctl). this timeout is based on an rc delay so that the clock monitor can operate without any mcu clocks. clock monitor timeouts are shown in table 10-1 . table 10-1. clock monitor timeout supply range 5 v 10 % 2?20 s
clock generation module (cgm) clock registers m68hc12b family ? rev. 9.0 data sheet motorola clock generation module (cgm) 123 10.7 clock registers this section describes the clock registers. all register addresses shown reflect the reset state. registers may be mapped to any 2-kbyte space. 10.7.1 slow mode divider register sldv2?sldv0 ? slow mode divisor selector bits the value 2 raised to the power indicated by these three bits produces the slow mode frequency divider. the range of the divider is 2 to 128 by steps of power of 2. when the bits are clear, the divider is bypassed. table 10-2 shows the divider for all bit c onditions and the resulting bus rate for three example oscillator frequencies. address: $00e0 bit 7654321bit 0 read:00000 sldv2 sldv1 sldv0 write: reset:00000000 = unimplemented figure 10-5. slow mode divider register (slow) table 10-2. slow mode register divider rates sldv2 sldv1 sldv0 divider (2 x ) bus rate (16-mhz oscillator) bus rate (8-mhz oscillator) bus rate (4-mhz oscillator) 0 0 0 off 8 mhz 4 mhz 2 mhz 0 0 1 2 4 mhz 2 mhz 1 mhz 0 1 0 4 2 mhz 1 mhz 500 khz 0 1 1 8 1 mhz 500 khz 250 khz 1 0 0 16 500 khz 250 khz 125 khz 1 0 1 32 250 khz 125 khz 62.5 khz 1 1 0 64 125 khz 62.5 khz 31.2 khz 1 1 1 128 62.5 khz 31.2 khz 15.6 khz
clock generation module (cgm) data sheet m68hc12b family ? rev. 9.0 124 clock generation module (cgm) motorola 10.7.2 real-time interrupt control register read: anytime write: varies on a bit-by-bit basis rtie ? real-time interrupt enable bit write anytime. 0 = interrupt requests from rti are disabled. 1 = interrupt is requested when rti is set. rswai ? rti and cop stop while in wait bit write once in normal modes, anytime in special modes. 0 = allows the rti and cop to continue running in wait 1 = disables both the rti and cop when the part goes into wait rsbck ? rti and cop stop while in background debug mode bit write once in normal modes, anytime in special modes. 0 = allows the rti and cop to continue running while in background mode 1 = disables rti and cop when the part is in background mode (useful for emulation) rtbyp ? real-time interrupt divider chain bypass bit write is not allowed in normal modes, anytime in special modes. 0 = divider chain functions normally. 1 = divider chain is bypassed, allows faster testing. the divider chain is normally p divided by 2 13 , when bypass becomes p divided by 4. rtr2, rtr1, and rtr0 ? real-time interrupt rate select bits write anytime. rate select for real-time interrupt. the e clock is used for this module. address: $0014 bit 7654321bit 0 read: rtie rswai rsbck 0 rtbyp rtr2 rtr1 rtr0 write: reset:00000000 = unimplemented figure 10-6. real-time interrupt control register (rtictl)
clock generation module (cgm) clock registers m68hc12b family ? rev. 9.0 data sheet motorola clock generation module (cgm) 125 10.7.3 real-time interrupt flag register rtif ? real-time interrupt flag bit this bit is cleared automatically by a wr ite to this register with this bit set. 0 = timeout has not yet occurred. 1 = set when the timeout period is met 10.7.4 cop control register read: anytime write: varies on a bit by bit basis table 10-3. real-time interrupt rates rtr2 rtr1 rtr0 divide e by: timeout period e = 4.0 mhz timeout period e = 8.0 mhz 000 off off off 001 2 13 2.048 ms 1.024 ms 010 2 14 4.096 ms 2.048 ms 011 2 15 8.196 ms 4.096 ms 100 2 16 16.384 ms 8.196 ms 101 2 17 32.768 ms 16.384 ms 110 2 18 65.536 ms 32.768 ms 111 2 19 131.72 ms 65.536 ms address: $0015 bit 7654321bit 0 read: rtif0000000 write: reset:00000000 figure 10-7. real-time interrupt flag register (rtiflg) address: $0016 bit 7654321bit 0 read: cme fcme fcm fcop disr cr2 cr1 cr0 write: normal reset:00000001 special reset:00001001 figure 10-8. cop control register (copctl)
clock generation module (cgm) data sheet m68hc12b family ? rev. 9.0 126 clock generation module (cgm) motorola cme ? clock monitor enable bit write anytime. if fcme is set, this bit has no meaning or effect. 0 = clock monitor is disabled; slow clocks and stop instruction may be used. 1 = slow or stopped clocks (including the stop instruction) cause a clock reset sequence. fcme ? force clock monitor enable bit write once in normal modes, anytime in special modes. in normal modes, when this bit is set, the clock moni tor function cannot be disabled until a reset occurs. 0 = clock monitor follows the state of the cme bit. 1 = slow or stopped clocks cause a clock reset sequence. to use both stop and clock monitor, the cme bit should be cleared prior to executing a stop instruction and set after recovery from stop. always keep fcme = 0, if stop will be used. fcm ? force clock monitor reset bit writes are not allowed in normal modes, anytime in special modes. if disr is set, this bit has no effect. 0 = normal operation 1 = force a clock monitor reset, if clock monitor is enabled. fcop ? force cop watchdog reset bit writes are not allowed in normal modes; can be written anytime in special modes. if disr is set, this bit has no effect. 0 = normal operation 1 = force a cop reset, if cop is enabled. disr ? disable resets from co p watchdog and clock monitor bit writes are not allowed in normal modes, anytime in special modes. 0 = normal operation 1 = regardless of other control bit states, cop and clock monitor do not generate a system reset. cr2, cr1, and cr0 ? cop watchdog timer rate select bit the cop system is driven by a constant frequency of e/2 13 . (rtbyp in the rtictl register allows all but two stages of this divider to be bypassed for testing in special modes only.) these bits specify an additional division factor to arrive at the cop timeout rate. the clo ck used for this module is the e clock. write once in normal modes, anytime in special modes.
clock generation module (cgm) clock registers m68hc12b family ? rev. 9.0 data sheet motorola clock generation module (cgm) 127 10.7.5 arm/reset cop timer register always reads $00. writing $55 to this address is the first step of the cop watchdog sequence. writing $aa to this address is the second step of the cop watchdog sequence. other instructions may be executed between these writes but both must be completed in the correct order prior to timeout to avoid a watchdog reset. writing anything other than $55 or $aa causes a cop reset to occur. table 10-4. cop watchdog rates (rtbyp = 0) cr2 cr1 cr0 divide e by: at e = 4.0-mhz timeout 0 to +2.048 ms at e = 8.0-mhz timeout 0 to +1.024 ms 0 0 0 off off off 001 2 13 2.048 ms 1.024 ms 010 2 15 8.1920 ms 4.096 ms 011 2 17 32.768 ms 16.384 ms 100 2 19 131.072 ms 65.536 ms 101 2 21 524.288 ms 262.144 ms 110 2 22 1.048 s 524.288 ms 111 2 23 2.097 s 1.048576 s address: $0017 bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 10-9. arm/reset cop timer register (coprst)
clock generation module (cgm) data sheet m68hc12b family ? rev. 9.0 128 clock generation module (cgm) motorola 10.8 clock divider chains figure 10-10 , figure 10-11 , figure 10-12 , and figure 10-13 summarize the clock divider chains for these peripherals:  sci ? serial peripheral interface  bdlc ? byte data link communications  rti ? real-time interrupt  cop ? computer operating properly  tim ? standard timer module  ect ? enhanced capture timer  spi ? serial peripheral interface  atd ? analog-to-digital converter  bdm ? background debug mode figure 10-10. clock chain for sci, bdlc, rti, and cop p clock bits: rtr2, rtr1, and rtr0 bits: cr2, cr1, and cr0 2 4 0:0:0 0:0:1 0:1:0 0:1:1 1:0:0 1:0:1 1:1:0 1:1:1 2 2 2 2 2 2 0:0:0 0:0:1 0:1:0 0:1:1 1:0:0 1:0:1 1:1:0 1:1:1 4 4 4 2 4 2 register: copctl register: rtictl 2 11 2 2 bit: rtbyp register: rtictl 0:0 0:1 1:0 1:1 2 2 2 bits: r1, r0 register: bcr1 to bdlc to rti to cop sc0bd modulus divider: 1, 2, 3, 4, 5, 6, ..., 8190, 8191 sci0 receive baud rate (16x) sci0 transmit baud rate (1x)
clock generation module (cgm) clock divider chains m68hc12b family ? rev. 9.0 data sheet motorola clock generation module (cgm) 129 figure 10-11. clock chain for tim bits: pr2, pr1, and pr0 p clock 1:0:0 1:0:1 1:1:0 1:1:1 port t7 pamod paclk paclk/256 paclk/65536 (paov) gate logic bits: paen, clk1, and clk0 0:x:x ten paen 0:0:0 0:0:1 0:1:0 0:1:1 1:0:0 1:0:1 2 2 2 2 2 2 register: pactl register: tmsk2 pulse acc high byte to tim counter pulse acc low byte
clock generation module (cgm) data sheet m68hc12b family ? rev. 9.0 130 clock generation module (cgm) motorola figure 10-12. clock chain for ect bits: pr2, pr1, and pr0 0:0:0 0:0:1 0:1:0 0:1:1 1:0:0 1:0:1 1:1:0 1:1:1 2 2 2 2 2 2 0:x:x 1:0:0 1:0:1 1:1:0 1:1:1 register: tmsk2 0:0 0:1 1:0 1:1 2 4 2 bits: mcpr1 and mcpr0 register: mcctl 2 ten mclk mcen modulus down gate logic to timer main counter pulse acc high byte paclk/65536 (paov) paclk/256 pulse acc low byte bits: paen, clk1, and clk0 register: pactl port t7 paen pamod paclk
clock generation module (cgm) clock divider chains m68hc12b family ? rev. 9.0 data sheet motorola clock generation module (cgm) 131 figure 10-13. clock chain for spi, atd, and bdm p clock bits : spr2, spr1, and spr0 e clock bkgd bdm bit clock: receive: detect falling edge, count 12 e clocks, sample input transmit 1: detect falling edge, count 6 e clocks while output is high impedance, drive out 1 e cycle pulse high, high-impedance output again transmit 0: detect falling edge, drive out low, count 9 e clocks, drive out 1 e cycle pulse high, high-impedance output pin synchronizer logic 2 0:0:0 0:0:1 0:1:0 0:1:1 1:0:0 1:0:1 1:1:0 1:1:1 2 2 2 2 2 2 2 2 register: sp0br to atd spi bit rate 5-bit modulus counter (pr0-pr4) bkgd in bkgd out bkgd direction
clock generation module (cgm) data sheet m68hc12b family ? rev. 9.0 132 clock generation module (cgm) motorola
m68hc12b family ? rev. 9.0 data sheet motorola pulse-width modulator (pwm) 133 data sheet ? m68hc12b family section 11. pulse-width modulator (pwm) 11.1 introduction the pulse-width modulator (pwm) subsystem provides four independent 8-bit pwm waveforms or two 16-bit pwm waveforms or a combination of one 16-bit and two 8-bit pwm waveforms. each wave form channel has a programmable period and a programmable duty cycle as well as a dedicated counter. a flexible clock select scheme allows four different cloc k sources to be used with the counters. each of the modulators can create independent, continuous waveforms with software-selectable duty rates from 0 percent to 100 percent. the pwm outputs can be programmed as left-aligned outpu ts or center-aligned outputs. see figure 11-1 , figure 11-2 , and figure 11-3 . the period and duty registers are double buffered so that if they change while the channel is enabled, the change does not take ef fect until the counter rolls over or the channel is disabled. if the channel is not enabled, then writes to the period and/or duty register go directly to the latches as well as the buffer, thus ensuring that the pwm output is always either the old waveform or the new waveform, not some variation in between. a change in duty or period can be forced in to immediate effect by writing the new value to the duty and/or period registers and then writing to the counter. this causes the counter to reset and the new duty and/or period values to be latched. in addition, since the counter is readable it is possible to know where the count is with respect to the duty value and software can be used to make adjustments by turning the enable bit off and on. the four pwm channel outputs share general-purpose port p pins. enabling pwm pins takes precedence over the general-purpose port. when pwm outputs are not in use, the port pins may be used for discrete input/output.
pulse-width modulator (pwm) data sheet m68hc12b family ? rev. 9.0 134 pulse-width modulator (pwm) motorola figure 11-1. block diagram of pwm left-aligned output channel figure 11-2. block diagram of pwm center-aligned output channel gate pwcntx 8-bit compare pwdtyx 8-bit compare = pwperx up counter only from port p data register to pin driver ppolx clock source (eclk) clock edge sync reset centr = 0 mux mux s r q q pwper pwdty pwenx ppol = 0 ppol = 1 gate pwcntx 8-bit compare pwdtyx 8-bit compare = pwperx reset from port p data register to pin driver ppolx clock source (eclk) clock edge sync centr = 1 mux mux t q q pwdty pwenx ppol = 0 ppol = 1 duty cycle period pwper 2 (pwper ? pwdty) 2 pwdty up /down counter with reset upon enable
pulse-width modulator (pwm) pwm register descriptions m68hc12b family ? rev. 9.0 data sheet motorola pulse-width modulator (pwm) 135 figure 11-3. pwm clock sources 11.2 pwm regist er descriptions this section provides descriptions of the pwm registers. 11.2.1 pwm clocks and concatenate register read: anytime write: anytime 8-bit down counter pclk2 mux pclk3 mux clock to pwm channel 2 clock to pwm channel 3 2 pwscnt1 8-bit scale register pwscal1 clock b clock s1** **clock s1 = (clock b)/2, (clock b)/4, (clock b)/6,... (clock b)/512 2 0:0:0 0:0:1 0:1:0 0:1:1 1:0:0 1:0:1 1:1:0 1:1:1 2 2 2 2 2 2 0:0:0 0:0:1 0:1:0 0:1:1 1:0:0 1:0:1 1:1:0 1:1:1 8-bit down counter pclk0 mux pclk1 mux clock to pwm channel 0 clock to pwm channel 1 2 pwscnt0 8-bit scale register pwscal0 clock a clock s0* *clock s0 = (clock a)/2, (clock a)/4, (clock a)/6,... (clock a)/512 register: bits: pckb2, pckb0 pckb1, = 0 = 0 bits: pcka2, pcka0 pcka1, pwpres psbck limbdm eclk psbck is bit 0 of pwctl register. internal signal limbdm is 1 if the mcu is in background debug mode. address: $0040 bit 7654321bit 0 read: con23 con01 pcka2 pcka1 pcka0 pckb2 pckb1 pckb0 write: reset:00000000 figure 11-4. pwm clocks and concatenate register (pwclk)
pulse-width modulator (pwm) data sheet m68hc12b family ? rev. 9.0 136 pulse-width modulator (pwm) motorola con23 ? concatenate pwm channels 2 and 3 bit when concatenated, channel 2 becomes the high-order byte and channel 3 becomes the low-order byte. channel 2 output pin is used as the output for this 16-bit pwm (bit 2 of port p). channel 3 clock-select control bits determines the clock source. 0 = channels 2 and 3 are separate 8-bit pwms. 1 = channels 2 and 3 are concatenated to create one 16-bit pwm channel. con01 ? concatenate pwm channels 0 and 1 bit when concatenated, channel 0 becomes the high-order byte and channel 1 becomes the low-order byte. channel 0 output pin is used as the output for this 16-bit pwm (bit 0 of port p). channel 1 clock-select control bits determine the clock source. 0 = channels 0 and 1 are separate 8-bit pwms. 1 = channels 0 and 1 are concatenated to create one 16-bit pwm channel. pcka2?pcka0 ? prescaler for clock a bits clock a is one of two clock sources which may be used for channels 0 and 1. these three bits determine the rate of clock a, as shown in table 11-1 . pckb2?pckb0 ? prescaler for clock b bits clock b is one of two clock sources which may be used for channels 2 and 3. these three bits determine the rate of clock b, as shown in table 11-1 . 11.2.2 pwm clock select and polarity register read: anytime write: anytime table 11-1. clock a and clock b prescaler pcka2 (pckb2) pcka1 (pckb1) pcka0 (pckb0) value of clock a (b) 000 e 001 e 2 010 e 4 011 e 8 100e 16 101e 32 110e 64 111e 128 address: $0041 bit 7654321bit 0 read: pclk3 pclk2 pclk1 pclk0 ppol3 ppol2 ppol1 ppol0 write: reset:00000000 figure 11-5. pwm clock select and polarity register (pwpol)
pulse-width modulator (pwm) pwm register descriptions m68hc12b family ? rev. 9.0 data sheet motorola pulse-width modulator (pwm) 137 pclk3 ? pwm channel 3 clock select bit 0 = clock b is the clock source for channel 3. 1 = clock s1 is the clock source for channel 3. pclk2 ? pwm channel 2 clock select bit 0 = clock b is the clock source for channel 2. 1 = clock s1 is the clock source for channel 2. pclk1 ? pwm channel 1 clock select bit 0 = clock a is the clock source for channel 1. 1 = clock s0 is the clock source for channel 1. pclk0 ? pwm channel 0 clock select bit 0 = clock a is the clock source for channel 0. 1 = clock s0 is the clock source for channel 0. if a clock select is changed while a pwm signal is being generated, a truncated or stretched pulse may occur during the transition. ppol3 ? pwm channel 3 polarity bit 0 = channel 3 output is low at the beginning of the period, high when the duty count is reached. 1 = channel 3 output is high at the beginning of the period, low when the duty count is reached. ppol2 ? pwm channel 2 polarity bit 0 = channel 2 output is low at the beginning of the period, high when the duty count is reached. 1 = channel 2 output is high at the beginning of the period, low when the duty count is reached. ppol1 ? pwm channel 1 polarity bit 0 = channel 1 output is low at the beginning of the period, high when the duty count is reached. 1 = channel 1 output is high at the beginning of the period, low when the duty count is reached. ppol0 ? pwm channel 0 polarity bit 0 = channel 0 output is low at the beginning of the period, high when the duty count is reached. 1 = channel 0 output is high at the beginning of the period, low when the duty count is reached. depending on the polarity bit, the duty regi sters may contain the count of either the high time or the low time. if the polarity bit is 0 and left alignment is selected, the duty registers contain a count of the low time. if the polarity bit is 1, the duty registers contain a count of the high time.
pulse-width modulator (pwm) data sheet m68hc12b family ? rev. 9.0 138 pulse-width modulator (pwm) motorola 11.2.3 pwm enable register read: anytime write: anytime setting any of the pwenx bits causes the associated port p line to become an output regardless of the state of the associated data direction register (ddrp) bit. this does not change the state of the data direction bit. when pwenx returns to 0, the data direction bit controls i/o directi on. on the front end of the pwm channel, the scaler clock is enabled to the pwm circuit by the pwenx enable bit being high. when all four pwm channels are disabled, the prescaler counter shuts off to save power. there is an edge-synchronizing gate circuit to guarantee that the clock is only enabled or disabled at an edge. pwen3 ? pwm channel 3 enable bit the pulse modulated signal wi ll be available at port p bit 3 when its clock source begins its next cycle. 0 = channel 3 disabled 1 = channel 3 enabled pwen2 ? pwm channel 2 enable bit the pulse modulated signal wi ll be available at port p bit 2 when its clock source begins its next cycle. 0 = channel 2 disabled 1 = channel 2 enabled pwen1 ? pwm channel 1 enable bit the pulse modulated signal wi ll be available at port p bit 1 when its clock source begins its next cycle. 0 = channel 1 disabled 1 = channel 1 enabled pwen0 ? pwm channel 0 enable bit the pulse modulated signal wi ll be available at port p bit 0 when its clock source begins its next cycle. 0 = channel 0 disabled 1 = channel 0 enabled address: $0042 bit 7654321bit 0 read:0000 pwen3 pwen2 pwen1 pwen0 write: reset:00000000 = unimplemented figure 11-6. pwm enable register (pwen)
pulse-width modulator (pwm) pwm register descriptions m68hc12b family ? rev. 9.0 data sheet motorola pulse-width modulator (pwm) 139 11.2.4 pwm prescale counter read: anytime write: only in special mode (smod = 1) pwpres is a free-running 7-bit counter. 11.2.5 pwm scale register 0 read: anytime write: anytime a write causes the scaler counter pwscnt0 to load the pwscal0 value unless it is in special mode with discal = 1 in the pwtst register. pwm channels 0 and 1 can select clock s0 (scaled) as its input clock by setting the control bit pclk0 and pclk1 respectively. cl ock s0 is generated by dividing clock a by the value in the pwscal0 register plus one and dividing again by two. when pwscal0 = $ff, clock a is divided by 256 then divided by two to generate clock s0. address: $0043 bit 7654321bit 0 read: 0 bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 = unimplemented figure 11-7. pwm prescale counter (pwpres) address: $0044 bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 11-8. pwm scale register 0 (pwscal0)
pulse-width modulator (pwm) data sheet m68hc12b family ? rev. 9.0 140 pulse-width modulator (pwm) motorola 11.2.6 pwm scale counter 0 value read: anytime pwscnt0 is a down-counter that, upon reaching $00, loads the value of pwscal0. 11.2.7 pwm scale register 1 read: anytime write: anytime a write causes the scaler counter pwscnt1 to load the pwscal1 value unless it is in special mode with discal = 1 in the pwtst register. pwm channels 2 and 3 can select clock s1 (scaled) as its input clock by setting the control bit pclk2 and pclk3 respectively. cl ock s1 is generated by dividing clock b by the value in the pwscal1 register plus one and dividing again by two. when pwscal1 = $ff, clock b is divided by 256 then divided by two to generate clock s1. 11.2.8 pwm scale counter 1 value read: anytime pwscnt1 is a down-counter that, upon reaching $00, loads the value of pwscal1. address: $0045 bit 7654321bit 0 read: bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 write: reset:00000000 = unimplemented figure 11-9. pwm scale counter register 0 (pwscnt0) address: $0046 bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 11-10. pwm scale register 1 (pwscal1) address: $0047 bit 7654321bit 0 read: bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 write: reset:00000000 = unimplemented figure 11-11. pwm scale counter 1 value (pwscnt1)
pulse-width modulator (pwm) pwm register descriptions m68hc12b family ? rev. 9.0 data sheet motorola pulse-width modulator (pwm) 141 11.2.9 pwm channel counters 0?3 read: anytime write: anytime a write causes the pwm counter to reset to $00. in special mode, if discr = 1, a write does not reset the pwm counter. each counter may be read anytime without affecting the count or the operation of the corresponding pwm channel. writes to a counter cause the counter to be reset to $00 and force an immediate load of both duty and period registers with new values. to avoid a truncated pwm period, write to a counter while the counter is disabled. in left-aligned output mode, resetting the counter and starting the waveform output is controlled by a match between the period register and the value in the counter. in center-aligned output mode, the counters operate as up/down address: $0048 bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 11-12. pwm channel counter 0 (pwcnt0) address: $0049 bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 11-13. pwm channel counter 1 (pwcnt1) address: $004a bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 11-14. pwm channel counter 2 (pwcnt2) address: $004b bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 11-15. pwm channel counter 3 (pwcnt3)
pulse-width modulator (pwm) data sheet m68hc12b family ? rev. 9.0 142 pulse-width modulator (pwm) motorola counters, where a match in period changes th e counter direction. the duty register changes the state of the output during the period to determine the duty. when a channel is enabled, the associated pwm counter starts at the count in the pwcntx register using the clock selected for that channel. in special mode, when discp = 1 and is co nfigured for left-aligned output, a match of period does not reset the associated pwm counter. 11.2.10 pwm channel period registers 0?3 read: anytime write: anytime the value in the period register determines the period of the associated pwm channel. if written while the channel is enabled, the new value takes effect when address: $004c bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:11111111 figure 11-16. pwm channel period register 0 (pwper0) address: $004d bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:11111111 figure 11-17. pwm channel period register 1 (pwper1) address: $004e bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:11111111 figure 11-18. pwm channel period register 2 (pwper2) address: $004f bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:11111111 figure 11-19. pwm channel period register 3 (pwper3)
pulse-width modulator (pwm) pwm register descriptions m68hc12b family ? rev. 9.0 data sheet motorola pulse-width modulator (pwm) 143 the existing period terminates , forcing the counter to reset. the new period is then latched and is used until a new period value is written. reading this register returns the most recent value written. to start a new period immediately, write the new period value and then write the counter, forcing a new period to start with the new period value. period = channel-clock-period (pwper + 1) (centr = 0) period = channel-clock-period pwper 2 (centr = 1) 11.2.11 pwm channel duty registers 0?3 read: anytime write: anytime the value in each duty register determines the duty of the associated pwm channel. when the duty value is equal to the counter value, the output changes address: $0050 bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:11111111 figure 11-20. pwm channel duty register 0 (pwdty0) address: $0051 bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:11111111 figure 11-21. pwm channel duty register 1 (pwdty1) address: $0052 bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:11111111 figure 11-22. pwm channel duty register 2 (pwdty2) address: $0053 bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:11111111 figure 11-23. pwm channel duty register 3 (pwdty3)
pulse-width modulator (pwm) data sheet m68hc12b family ? rev. 9.0 144 pulse-width modulator (pwm) motorola state. if the register is written while the channel is enabled, the new value is held in a buffer until the counter rolls over or the channel is disabled. reading this register returns the most recent value written. if the duty register is greater than or equal to the value in the period register, there is no duty change in state. if the duty register is set to $ff, the output is always in the state which would normally be the state opposite the ppolx value. left-aligned output mode (centr = 0): duty cycle = [(pwdtyx + 1) / (pwperx + 1)] 100% (ppolx = 1) duty cycle = [(pwperx ? pwdtyx) / (pwperx + 1)] 100% (ppolx = 0) center-aligned output mode (centr = 1): duty cycle = [(pwperx ? pwdtyx) / pwperx] 100% (ppolx = 0) duty cycle = (pwdtyx / pwperx) 100% (ppolx = 1) 11.2.12 pwm control register read: anytime write: anytime pswai ? pwm halts while in wait mode bit 0 = continue pwm main clock generator while in wait mode. 1 = halt pwm main clock generator when the part is in wait mode. centr ? center-aligned output mode bit to avoid irregularities in the pwm output mode, write the centr bit only when pwm channels are disabled. 0 = pwm channels operate in left-aligned output mode. 1 = pwm channels operate in center-aligned output mode. rdpp ? reduced drive of port p bit 0 = full drive for all port p output pins 1 = reduced drive for all port p output pins pupp ? pullup port p enable bit 0 = disable port p pullups 1 = enable pullups for all port p input pins. psbck ? pwm stops while in background mode bit 0 = allows pwm to continue while in background mode 1 = disable pwm input clock while in background mode. address: $0054 bit 7654321bit 0 read: 0 0 0 pswai centr rdpp pupp psbck write: reset:00000000 = unimplemented figure 11-24. pwm control register (pwctl)
pulse-width modulator (pwm) pwm register descriptions m68hc12b family ? rev. 9.0 data sheet motorola pulse-width modulator (pwm) 145 11.2.13 pwm special mode register read: anytime write: only in special mode (smodn = 0) these bits are available only in special mode and are reset in normal mode. discr ? disable channel counter reset bit this bit disables the normal operation of resetting the channel counter when the channel counter is written. 0 = normal operation 1 = write to pwm channel counter does not reset channel counter. discp ? disable compare count period bit 0 = normal operation 1 = in left-aligned output mode, match of the period does not reset the associated pwm counter register. discal ? disable scale counter loading bit this bit disables the normal operation of loading scale counters on a write to the associated scale register. 0 = normal operation 1 = write to pwscal0 and pwscal1 does not load scale counters. 11.2.14 port p data register read: anytime write: anytime pwm functions share port p pins 3 to 0 and take precedence over the general-purpose port when enabled. when conf igured as input, a read returns the address: $0055 bit 7654321bit 0 read: discr discp discal 00000 write: reset:00000000 = unimplemented figure 11-25. pwm special mode register (pwtst) address: $0056 bit 7654321bit 0 read: pp7 pp6 pp5 pp4 pp3 pp2 pp1 pp0 write: pwm pwm3 pwm2 pwm1 pwm0 reset: unaffected by reset figure 11-26. port p data register (portp)
pulse-width modulator (pwm) data sheet m68hc12b family ? rev. 9.0 146 pulse-width modulator (pwm) motorola pin level. when configured as output, a read returns the latched output data. a write drives associated pins only if configured for output and the corresponding pwm channel is not enabled. after reset, all pins are general-purpose, high-impedance inputs. 11.2.15 port p data direction register read: anytime write: anytime ddrp determines pin direction of port p when used for general-purpose i/o. when cleared, i/o pin is configured for input. when set, i/o pin is configured for output. 11.3 pwm boundary cases the boundary conditions for the pwm channel duty registers and the pwm channel period registers caus e the results shown in table 11-2 . 11.4 using the outp ut compare 7 feature to generate a pwm this timer exercise is intended to utilize the output compare function along with the output compare 7 new feature to generate a pwm waveform. it must allow for the duty used to drive a dc motor on the udlp1 board. the registers must be initialized accordingly tc7 = period and tc5 = high time (duty cycle). see figure 11-28 . note: to verify program is working the dc motor must turn, the frequency, high time, and duty cycle must displayed on the lcd. address: $0057 bit 7654321bit 0 read: ddp7 ddp6 ddp5 ddp4 ddp3 ddp2 ddp1 ddp0 write: reset:00000000 figure 11-27. port p data direction register (ddrp) table 11-2. pwm boundary conditions pwdtyx pwperx ppolx output $ff > $00 1 low $ff > $00 0 high pwperx ? 1 high pwperx ? 0 low ? $00 1 high ? $00 0 low
pulse-width modulator (pwm) using the output compare 7 feature to generate a pwm m68hc12b family ? rev. 9.0 data sheet motorola pulse-width modulator (pwm) 147 figure 11-28. example waveform 11.4.1 pwm period calculation these parameters were used to calculate the high-time values shown in table 11-3 :  period = $1000 (hex) = 4096 (decimal)  e clock = 8 mhz  prescaler = 4  frequency = (8 mhz) / (#clocks_c ount*prescaler) = (8 mhz) (4096*4) = 500 hz  if period ($4096 clocks) => frequency = 500 hz 11.4.2 equipment for this exercise, use the m68hc912b32evb emulation board. high time high time = duty cycle period table 11-3. pwm period calculations high-time values duty cycle hex count decimal count $0020 32 0% $0040 64 1.5% $0080 128 3.1% $0100 256 6.25% $0200 512 12.50% $0040 1024 25.00% $0080 2048 50.00% $0996 2454 60.00% $0c00 3072 75.00% $0d9a 3482 85.00% $1000 4096 100.00%
pulse-width modulator (pwm) data sheet m68hc12b family ? rev. 9.0 148 pulse-width modulator (pwm) motorola 11.4.3 code listing note: a comment line is deliminted by a semi-c olon. if there is no code before comment, an ?;? must be placed in the first colu mn to avoid assembly errors. include 'equates.asm' ; equates for all registers ; ---------------------------------------------------------------------- ; main program ; ---------------------------------------------------------------------- org $7000 ; 16k on-board ram, user code data area, ; ; start main program at $7000 main: bsr timerinit ; subroutine used to initialize the timer: ; ; out. comp. chan. using oc7 & oc5, ; ; no interrupts ; ; oc7 = period & oc5 = high time of pwm done: bra done ; branch to itself, convinient for breakpoint ;* -------------------------------------------------------- ;* subroutine timerinit: initialize timer for pwm on oc5 ;* -------------------------------------------------------- timerinit: clr tmsk1 ; disable all interrupts movb #$0a,tmsk2 ; disable overflow interrupt, disable pull-up ; ; resistor function with normal drive capability ; ; and cntr reset by a succesful oc7 compare, ; ; prescaler = sys clock / 4. movb #$88,tctl1 ; init. oc5 to clear ouput line to zero on ; ; successful compare. movb #$a0,tios ; select channel 5 and 7 to act as output compare. movb #$20,oc7m ; initialize oc7 compare to affect oc5 pin(oc7m) movb #$20,oc7d ; enable oc7 to set output compare 5 pin high(oc7d). movw #$0800,tc7h ; load tc7 with "period" of the pwm movw #$0400,tc5h ; load tc5 with "high time" of the pwm. movb #$80,tscr ; enable timer, timer runs during wait state, ; ; and while in background mode, also clear flags ; ; normally. rts ; return from subroutine
m68hc12b family ? rev. 9.0 data sheet motorola standard timer module (tim) 149 data sheet ? m68hc12b family section 12. standard timer module (tim) 12.1 introduction the standard timer module (tim) for the mc68hc912b32 and mc68hc(9)12bc32 consists of a 16-bit software-programmable counter driven by a prescaler. it contains eight complete 16-bit input capture/output compare channels and one 16-bit pulse accumulator. see figure 12-1 . the mc68hc12be32 contains an enhanced capture timer (ect). the timer on the mc68hc12be32 is backward compatible with code used on the mc68hc912b32. see section 13. enhanced capture timer (ect) module for technical information on this timer. this timer can be used for many pur poses, including input waveform measurements while simultaneously generating an output waveform. pulse widths can vary from less than a microsecond to many seconds. it can also generate pulse-width modulator (pwm) si gnals without cpu intervention. 12.2 timer registers input/output (i/o) pins default to general-pu rpose i/o lines until an internal function which uses that pin is specifically enabled. the timer overrides the state of the ddr to force the i/o state of each associated port line when an output compare using a port line is enabled. in these cases, the data direction bits will have no effect on these lines. when a pin is assigned to output an on-chip peripheral function, writing to this porttn bit does not affect the pin, but the data is stored in an internal latch such that if the pin becomes available for gener al-purpose output the driven level will be the last value written to the porttn bit.
standard timer module (tim) data sheet m68hc12b family ? rev. 9.0 150 standard timer module (tim) motorola 12.3 block diagram figure 12-1. timer block diagram tff pad int oc7 pad int mux pamod pulse accumulator control registers 64 tc7 pin logic module clock 16-bit counter buffer latch tc7 input pin polarity ctl gate clock ctl timpt pin logic function, direction, and polarity ctl control registers prescaler divide ctl input capture/ output compare register 16-bit comparator intermodule bus oc output ic input buffer latch ? tioc tcre counter reset tcnt reset tcnt 16-bit counter prescaler pr2, pr1, pr0 timer count register module clock tctl1 and tctl2
standard timer module (tim) block diagram m68hc12b family ? rev. 9.0 data sheet motorola standard timer module (tim) 151 12.3.1 timer input capture/output compare select register read: anytime write: anytime ios7?ios0 ?input capture or output compare channel designator bits 0 = corresponding channel acts as an input capture. 1 = corresponding channel acts as an output compare. 12.3.2 timer compare force register read: anytime, always returns $00 (1 state is transient) write: anytime foc7?foc0 ? force output com pare action bits for channels 7?0 a write to this register with the corresponding data bit(s) set causes the action which is programmed for output compare n to occur immediately. the action taken is the same as if a successful comparison had just taken place with the tcn register except that the interrupt flag does not get set. address: $0080 bit 7654321bit 0 read: ios7 ios6 ios5 ios4 ios3 ios2 ios1 ios0 write: reset:00000000 figure 12-2. timer input capture/output compare select register (tios) address: $0081 bit 7654321bit 0 read: foc7 foc6 foc5 foc4 foc3 foc2 foc1 foc0 write: reset:00000000 figure 12-3. timer compare force register (cforc)
standard timer module (tim) data sheet m68hc12b family ? rev. 9.0 152 standard timer module (tim) motorola 12.3.3 output compare 7 mask register read: anytime write: anytime the bits of oc7m correspond bit-for-bit with the bits of the timer port (portt). setting the oc7mn sets the corresponding port to be an output port regardless of the state of the ddrtn bit when the corresponding tiosn bit is set to be an output compare. this does not change the state of the ddrt bits. 12.3.4 output compare 7 data register read: anytime write: anytime the bits of oc7d correspond bit-for-bit with the bits of the timer port (portt). when a successful oc7 compare occurs, for each bit that is set in oc7m, the corresponding data bit in oc7d is stored to the corresponding bit of the timer port. when the oc7mn bit is set, a successful oc7 action will override a successful oc6?oc0 compare action during the same cycle; therefore, the ocn action taken will depend on the corresponding oc7d bit. address: $0082 bit 7654321bit 0 read: oc7m7 oc7m6 oc7m5 oc7m4 oc7m3 oc7m2 oc7m1 oc7m0 write: reset:00000000 figure 12-4. output compare 7 mask register (oc7m) address: $0083 bit 7654321bit 0 read: oc7d7 oc7d6 oc7d5 oc7d4 oc7d3 oc7d2 oc7d1 oc7d0 write: reset:00000000 figure 12-5. output compare 7 data register (oc7d)
standard timer module (tim) block diagram m68hc12b family ? rev. 9.0 data sheet motorola standard timer module (tim) 153 12.3.5 timer count register read: anytime write: has no meaning or effect in normal mode; only writable in special modes a full access for the counter register should take place in one clock cycle. a separate read/write for high byte and low byte will give a different result than accessing them as a word. the period of the first count after a write to the tcnt registers may be a different size because the write is not synchronized with the prescaler clock. 12.3.6 timer system control register read: anytime write: anytime ten ? timer enable bit if for any reason the timer is not active, there is no 64 clock for the pulse accumulator since the e 64 is generated by the timer prescaler. 0 = disables timer, including the counter; can be used for reducing power consumption 1 = allows timer to function normally address: $0084 bit 7654321bit 0 read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 address: $0085 bit 7654321bit 0 read: bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 write: reset:00000000 = unimplemented figure 12-6. timer count register (tcnt) address: $0086 bit 7654321bit 0 read: ten tswai tsbck tffca 0000 write: reset:00000000 = unimplemented figure 12-7. timer system control register (tscr)
standard timer module (tim) data sheet m68hc12b family ? rev. 9.0 154 standard timer module (tim) motorola tswai ? timer stops while in wait bit timer interrupts cannot be used to get the mcu out of wait. 0 = allows timer to continue running during wait 1 = disables timer when mcu is in wait mode tsbck ? timer stops while in background mode bit 0 = allows timer to continue running while in background mode 1 = disables timer when mcu is in background mode; useful for emulation tffca ? timer fast flag clear all bit 0 = allows timer flag cl earing to function normally 1 = for tflg1($8e), a read from an input capture or a write to the output compare channel ($90?$9f) causes the corresponding channel flag, cnf, to be cleared. for tflg2 ($8f), any access to the tcnt register ($84, $85) clears the tof flag. any access to the pacnt register ($a2 and $a3) clears the paovf and paif flags in the paflg register ($a1). this has the advantage of eliminati ng software overhead in a separate clear sequence. note: extra care is required to avoid accidental flag clearing due to unintended accesses. 12.3.7 timer control registers read: anytime write: anytime omn ? output mode oln ? output level these eight pairs of control bits are encoded to specify the output action to be taken as a result of a successful ocn compare (see table 12-1 ). when either omn or oln is 1, the pin associated with ocn becomes an output tied to ocn regardless of the state of the associated ddrt bit. address: $0088 bit 7654321bit 0 read: om7ol7om6ol6om5ol5om4ol4 write: reset:00000000 figure 12-8. timer control register 1 (tctl1) address: $0089 bit 7654321bit 0 read: om3ol3om2ol2om1ol1om0ol0 write: reset:00000000 figure 12-9. timer control register 2 (tctl2)
standard timer module (tim) block diagram m68hc12b family ? rev. 9.0 data sheet motorola standard timer module (tim) 155 read: anytime write: anytime edgnb and edgna ? input capture edge control bits these 8 pairs of control bits configure the input capture edge detector circuits. see table 12-2 . table 12-1. compare result output action omn oln action 0 0 timer disconnected from output pin logic 0 1 toggle ocn output line 1 0 clear ocn output line to 0 1 1 set ocn output line to 1 address: $008a bit 7654321bit 0 read: edg7b edg7a edg6b edg6a edg5b edg5a edg4b edg4a write: reset:00000000 figure 12-10. timer control register 3 (tctl3) address: $008b bit 7654321bit 0 read: edg3b edg3a edg2b edg2a edg1b edg1a edg0b edg0a write: reset:00000000 figure 12-11. timer control register 4 (tctl4) table 12-2. edge detector circuit configuration edgnb edgna configuration 0 0 capture disabled 0 1 capture on rising edges only 1 0 capture on falling edges only 1 1 capture on any edge (rising or falling)
standard timer module (tim) data sheet m68hc12b family ? rev. 9.0 156 standard timer module (tim) motorola 12.3.8 timer interrupt mask registers read: anytime write: anytime the bits in tmsk1 correspond bit-for-bit with the bits in the tflg1 status register. if cleared, the corresponding flag is disabl ed from causing a hardware interrupt. if set, the corresponding flag is enabled to cause a hardware interrupt. c7i?c0i ? input capture/output compare x interrupt enable bits read: anytime write: anytime toi ? timer overflow interrupt enable bit 0 = interrupt inhibited 1 = hardware interrupt requested when tof flag set pupt ? timer pullup resistor enable bit this enable bit controls pullup resistors on the timer port pins when the pins are configured as inputs. 0 = disable pullup resistor function 1 = enable pullup resistor function rdpt ? timer drive reduction bit this bit reduces the effective output dr iver size which can reduce power supply current and generated noise depending upon pin loading. 0 = normal output drive capability 1 = enable output drive reduction function address: $008c bit 7654321bit 0 read: c7i c6i c5i c4i c3i c2i c1i c0i write: reset:00000000 figure 12-12. timer interrupt mask 1 register (tmsk1) address: $008d bit 7654321bit 0 read: toi 0 pupt rdpt tcre pr2 pr1 pr0 write: reset:00000000 = unimplemented figure 12-13. timer interrupt mask 2 register (tmsk2)
standard timer module (tim) block diagram m68hc12b family ? rev. 9.0 data sheet motorola standard timer module (tim) 157 tcre ? timer counter reset enable bit this bit allows the timer counter to be reset by a successful output compare 7 event. 0 = counter reset inhibited and counter free runs 1 = counter reset by a successful output compare 7 if tc7 = $0000 and tcre = 1, tcnt stays at $0000 continuously. if tc7 = $ffff and tcre = 1, tof never gets set even though tcnt counts from $0000 through $ffff. pr2, pr1, and pr0 ? timer prescaler select bits these three bits specify the number of 2 stages that are to be inserted between the module clock and the timer counter. see table 12-3 . the newly selected prescale factor will not take effect until the next synchronized edge where all prescale counter stages equal 0. 12.3.9 timer interrupt flag registers read: anytime write: used in the clearing mechanism; set bits cause corresponding bits to be cleared tflg1 indicates when interrupt conditions hav e occurred. to clear a bit in the flag register, write a 1 to the bit. writing a logic 0 does not affect current status of the bit. when tffca bit in tscr register is set, a read from an input capture or a write into an output compare channel ($90?$9f) causes the corresponding channel flag cnf to be cleared. table 12-3. prescaler selection pr2 pr1 pr0 prescale factor 000 1 001 2 010 4 011 8 100 16 101 32 110 reserved 111 reserved address: $008e bit 7654321bit 0 read: c7f c6f c5f c4f c3f c2f c1f c0f write: reset:00000000 figure 12-14. timer interrupt flag 1 (tflg1)
standard timer module (tim) data sheet m68hc12b family ? rev. 9.0 158 standard timer module (tim) motorola c7f?c0f ? input capture/output compare channel n flag read: anytime write: used in the clearing mechanism; set bits cause corresponding bits to be cleared tflg2 indicates when interrupt conditions hav e occurred. to clear a bit in the flag register, set the bit to 1. any access to tcnt clears tflg2 register, if the tffca bit in tscr register is set. tof ? timer overflow flag set when 16-bit free-running timer overflows from $ffff to $0000. this bit is cleared automatically by a write to the tflg2 register with bit 7 set. for additional information, see the tcre control bit explanation found in 12.3.8 timer interrupt mask registers . 12.3.10 timer input capture/output compare registers address: $008f bit 7654321bit 0 read: tof0000000 write: reset:00000000 figure 12-15. timer interrupt flag 2 (tflg2) address: $0090 bit 7654321bit 0 read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 address: $0091 bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 12-16. timer input capture/output compare register 0 (tc0)
standard timer module (tim) block diagram m68hc12b family ? rev. 9.0 data sheet motorola standard timer module (tim) 159 address: $0092 bit 7654321bit 0 read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 address: $0093 bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 12-17. timer input capture/output compare register 1 (tc1) address: $0094 bit 7654321bit 0 read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 address: $0095 bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 12-18. timer input capture/output compare register 2 (tc2) address: $0096 bit 7654321bit 0 read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 address: $0097 bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 12-19. timer input capture/output compare register 3 (tc3)
standard timer module (tim) data sheet m68hc12b family ? rev. 9.0 160 standard timer module (tim) motorola address: $0098 bit 7654321bit 0 read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 address: $0099 bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 12-20. timer input capture/output compare register 4 (tc4) address: $009a bit 7654321bit 0 read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 address: $009b bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 12-21. timer input capture/output compare register 5 (tc5) address: $009c bit 7654321bit 0 read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 address: $009d bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 12-22. timer input capture/output compare register 6 (tc6)
standard timer module (tim) block diagram m68hc12b family ? rev. 9.0 data sheet motorola standard timer module (tim) 161 read: anytime write: anytime for output compare function; has no meaning or effect during input capture depending on the tios bit for the corres ponding channel, these registers are used to latch the value of the free-running counter when a defined transition is sensed by the corresponding input capture edge detector or to trigger an output action for output compare. 12.3.11 pulse accumulator control register read: anytime write: anytime paen ? pulse accumulator system enable bit 0 = pulse accumulator system disabled 1 = pulse accumulator system enabled paen is independent from ten. pamod ? pulse accumulator mode bit 0 = event counter mode 1 = gated time accumulation mode address: $009e bit 7654321bit 0 read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 address: $009f bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 12-23. timer input capture/output compare register 7 (tc7) address: $00a0 bit 7654321bit 0 read: 0 paen pamod pedge clk1 clk0 paovi pai write: reset:00000000 = unimplemented figure 12-24. pulse accumulator control register (pactl)
standard timer module (tim) data sheet m68hc12b family ? rev. 9.0 162 standard timer module (tim) motorola pedge ? pulse accumulator edge control bit for pamod = 0 (event counter mode) 0 = falling edges on the pulse accumu lator input pin (pt7/pai) cause the count to be incremented. 1 = rising edges on the pulse accumulator input pin cause the count to be incremented. for pamod = 1 (gated time accumulation mode) 0 = pulse accumulator input pin high enables e 64 clock to pulse accumulator and the trailing falling edge on the pulse accumulator input pin sets the paif flag. 1 = pulse accumulator input pin low enables e 64 clock to pulse accumulator and the trailing rising edge on the pulse accumulator input pin sets the paif flag. if the timer is not active (ten = 0 in tscr), there is no 64 clock since the e 64 clock is generated by the timer prescaler. clk1 and clk0 ? clock select bits if the pulse accumulator is disabled (paen = 0), the prescaler clock from the timer is always used as an input clock to the timer counter. the change from one selected clock to the other happens imm ediately after these bits are written. paovi ? pulse accumulator overflow interrupt enable bit 0 = interrupt inhibited 1 = interrupt requested if paovf is set pai ? pulse accumulator input interrupt enable bit 0 = interrupt inhibited 1 = interrupt requested if paif is set table 12-4. clock selection clk1 clk0 selected clock 0 0 use timer prescaler clock as timer counter clock 0 1 use paclk as input to timer counter clock 1 0 use paclk/256 as timer counter clock frequency 1 1 use paclk/65536 as timer counter clock frequency
standard timer module (tim) block diagram m68hc12b family ? rev. 9.0 data sheet motorola standard timer module (tim) 163 12.3.12 pulse accumulator flag register read: anytime write: anytime when the tffca bit in the tscr register is set, any access to the pacnt register clears all the flags in the paflg register. paovf ? pulse accumulator overflow flag set when the 16-bit pulse accumulator ov erflows from $ffff to $0000. this bit is cleared automatically by a write to the paflg register with bit 1 set. paif ? pulse accumulator input edge flag set when the selected edge is detected at the pulse accumulator input pin. in event mode, the event edge triggers paif . in gated time accumulation mode, the trailing edge of the gate signal at th e pulse accumulator input pin triggers paif. this bit is cleared automatically by a write to the paflg register with bit 0 set. 12.3.13 16-bit pulse accumulator count register read: anytime write: anytime full count register access should take place in one clock cycle. a separate read/write for high byte and low byte will give a different result than accessing them as a word. address: $00a1 bit 7654321bit 0 read: 000000paovfpaif write: reset:00000000 figure 12-25. pulse accumulator flag register (paflg) address: $00a2 bit 7654321bit 0 read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 address: $00a3 bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 12-26. 16-bit pulse accumulator count register (pacnt)
standard timer module (tim) data sheet m68hc12b family ? rev. 9.0 164 standard timer module (tim) motorola 12.3.14 timer test register read: anytime write: only in special mode (smodn = 0) tcbyp ? timer divider chain bypass bit 0 = normal operation 1 = 16-bit free-running timer counter is divided into two 8-bit halves and the prescaler is bypassed. the clock drives both halves directly. pcbyp ? pulse accumulator divider chain bypass bit 0 = normal operation 1 = 16-bit pulse accumulator counter is divided into two 8-bit halves and the prescaler is bypassed. the clock drives both halves directly. 12.3.15 timer port data register read: anytime; inputs return pin level; outputs return pin driver input level write: data stored in an internal latch; drives pins only if configured for output note: writes do not change pin state when the pin is configured for timer output. the minimum pulse width for pulse accumulator input should always be greater than two module clocks due to input synchronizer circuitry. the minimum pulse width for the input capture should always be greater than the width of two module clocks due to input synchronizer circuitry. address: $00ad bit 7654321bit 0 read:000000tcbyppcbyp write: reset:00000000 = unimplemented figure 12-27. timer test register (timtst) address: $00ae bit 7654321bit 0 read: pt7 pt6 pt5 pt4 pt3 pt2 pt1 pt0 write: reset:00000000 timer: i/oc7 i/oc6 i/oc5 i/oc4 i/oc3 i/oc2 i/oc1 i/oc0 pa: pai figure 12-28. timer port data register (portt)
standard timer module (tim) timer operation in modes m68hc12b family ? rev. 9.0 data sheet motorola standard timer module (tim) 165 12.3.16 data direction register for timer port read: anytime write: anytime 0 = configures the corresponding i/o pin for input only 1 = configures the corresponding i/o pin for output the timer forces the i/o state to be an output for each timer port pin associated with an enabled output compare. in these cases the data direction bits will not be changed, but they have no affect on t he direction of these pins. the ddrt will revert to controlling the i/o direction of a pin when the associated timer output compare is disabled. input captures do not override the ddrt settings. 12.4 timer operation in modes stop ? timer is off since both pclk and eclk are stopped. bdm ? timer keeps running, unless tsbck = 1. wait ? counters keep running, unless tswai = 1. normal ? timer keeps running, unless ten = 0. ten = 0 ? all timer operations are stopped, registers may be accessed. gated pulse accumulator 64 clock is also disabled. paen = 0 ? all pulse accumula tor operations are stopped. registers may be accessed. address: $00af bit 7654321bit 0 read: ddt7 ddt6 ddt5 ddt4 ddt3 ddt2 ddt1 ddt0 write: reset:00000000 figure 12-29. data direction register for timer port (ddrt)
standard timer module (tim) data sheet m68hc12b family ? rev. 9.0 166 standard timer module (tim) motorola 12.5 using the output compare function to g enerate a square wave this timer exercise is intended to utilize the output compare function to generate a square wave of predetermined duty cycle and frequency. square wave frequency 1000 hz, duty cycle 50% the program generates a square wave, 50 percent duty cycle, on output compare 2 (oc2). the signal will be m easured by the hc11 on the udlp1 board. it assumes a 8.0 mhz operating frequency for the e clock. the control registers are initialized to disable interrupts, configure for proper pin control action and also the tc2h register for desired compare value. the appropiate count must be calculated to achieve the desired frequency and duty cycle. for example: for a 50 percent duty, 1 khz signal each period must cons ist of 2048 counts or 1024 counts high and 1024 counts low. in essence a $0400 is added to generate a frequency of 1khz. 12.5.1 sample calculation to obtain period counts the sample calculation to obtain period counts is:  for 1000 hz frequency: ? e-clock = 8 mhz ? ic/oc resolution factor = 1/(e-clock/prescaler) ? if the prescaler = 4, then output compare resolution is 0.5 s  for a 1 khz, 50 percent duty cycle: ? 1/f = t = 1/1000 = 1 ms ? f for output compare = prescaler/e clock = 2 mhz figure 12-30. example waveform 12.5.2 equipment for this exercise, use the m68hc912b32evb emulation board. 0.5 ms number of clocks = f * d 1 ms therefore, #clocks = (2 mhz) * (0.5 ms) = 1024 = $0400
standard timer module (tim) using the output compare function to generate a square wave m68hc12b family ? rev. 9.0 data sheet motorola standard timer module (tim) 167 12.5.3 code listing note: a comment line is deliminted by a semi-c olon. if there is no code before comment, an ?;? must be placed in the first colu mn to avoid assembly errors. ---------------------------------------------------------------------- ; main program ; ---------------------------------------------------------------------- org $7000 ; 16k on-board ram, user code data area, ; ; start main program at $7000 main: bsr timerinit ; subroutine used to initialize the timer: ; ; output compare channel, no interrupts bsr sqwave ; subroutine to generate square wave done: bra done ; branch to itself, convinient for breakpoint ;* ----------------------------------------------------------------- ;* subroutine timerinit: initialize timer for output compare on oc2 ;* ----------------------------------------------------------------- timerinit: clr tmsk1 ; disable all interrupts movb #$02,tmsk2 ; disable overflow interrupt, disable pull-up ; ; resistor function with normal drive capability ;; and free running counter, prescaler = sys clock/4. movb #$10,tctl2 ; initialize oc2 to toggle on successful compare. movb #$04,tios ; select channel 2 to act as output compare. movw #$0400,tc2h ; load tc2 reg with initial compare value. movb #$80,tscr ; enable timer, timer runs during wait state, and ; ; while in background mode, also clear flags ; ; normally. rts ; return from subroutine ;* ------------------------------ ;* subroutine: sqwave ;* ------------------------------ sqwave: ;* ------- clearflg: ;* ------- ;* to clear the c2f flag: 1) read tflg1 when ;* c2f is set and then 2) write a logic "one" to c2f. ldaa tflg1 ; to clear oc2 flag, first it must be read, oraa #$04 ; then a "1" must be written to it staa tflg1 wtflg: brclr tflg1,#$04,wtflg ; wait (polling) for c2f flag ldd tc2h ; loads value of compare from tc2 reg. addd #$0400 ; add hex value of 500us high time std tc2h ; set-up next transition time in 500 us bra clearflg ; continuously add 500 us, branch to clearflag rts ; return from subroutine end ; end of program
standard timer module (tim) data sheet m68hc12b family ? rev. 9.0 168 standard timer module (tim) motorola
m68hc12b family ? rev. 9.0 data sheet motorola enhanced capture timer (ect) module 169 data sheet ? m68hc12b family section 13. enhanced ca pture timer (ect) module 13.1 introduction the m68hc12 enhanced capture timer (ect) module has the features of the m68hc12 standard timer (tim) module enhanc ed by additional features in order to enlarge the field of applications. these additional features are:  16-bit buffer register for four input capture (ic) channels  four 8-bit pulse accumulators: ? 8-bit buffer registers associated with the four buffered ic channels ? configurable as two 16-bit pulse accumulators  16-bit modulus down-counter with 4-bit prescaler  four user selectable delay counters for input noise immunity increase  main timer prescaler extended to 7-bit this section describes the standard timer found on the mc68hc912b32 as well as the additional features found on the mc68hc12be32. 13.2 basic timer overview the basic timer consists of a 16-bit, so ftware-programmable counter driven by a prescaler. this timer can be used for many purposes, including input waveform measurements while simultaneously generating an output waveform. pulse widths can vary from microseconds to many seconds. a full access for the counter registers or the input capture/output compare registers should take place in one cloc k cycle. accessing high byte and low byte separately for all of these registers may not yield the same result as accessing them in one word. 13.3 enhanced capture time r modes of operation the enhanced capture timer has eight input capture, output compare (ic/oc) channels same as on the m68hc12 standard timer (timer channels tc0?tc7). when channels are selected as input capture by selecting the iosx bit in the timer input capture/output compare select register (tios), they are called input capture (ic) channels.
enhanced capture timer (ect) module data sheet m68hc12b family ? rev. 9.0 170 enhanced capture timer (ect) module motorola four ic channels are the same as on the standard timer with one capture register which memorizes the timer value captured by an action on the associated input pin. four other ic channels, in addition to the capture register, also have one buffer called holding register. this permits the r egister to memorize two different timer values without generation of any interrupt. four 8-bit pulse accumulators are associated with the four buffered ic channels. each pulse accumulator has a holding register to memorize their value by an action on its external input. each pair of pulse accumulators can be used as a 16-bit pulse accumulator. the 16-bit modulus down-counter can contro l the transfer of the ic register?s contents and the pulse accumulators to the respective holding registers for a given period, every time the count reaches 0. the modulus down-counter can also be used as a stand-alone timebase with periodic interrupt capability. 13.3.1 ic channels the ic channels are composed of four standard ic registers and four buffered ic channels. an ic register is empty when it has been read or latched into the holding register. a holding register is empty when it has been read. 13.3.1.1 non-buffered ic channels the main timer value is memorized in the ic register by a valid input pin transition.  if the corresponding novwx bit of the input control overwrite register (icovw) is cleared, with a new occurrence of a capture, the contents of ic register are overwritten by the new value.  if the corresponding novwx bit of the icovw register is set, the capture register cannot be written unless it is empty. this will prevent the captured value to be overwritten until it is read. 13.3.1.2 buffered ic channels there are two modes of operations for the buffered ic channels. ic latch mode (see figure 13-1 ): when enabled (latq = 1), the main timer value is memorized in the ic register by a valid input pin transition. the value of the buffered ic register is latched to its holding register by the modulus counter for a given period when the count reaches 0, by a write $0000 to the modulus counter or by a write to iclat in the 16-bit modulus down-counter control register (mcctl).  if the corresponding novwx bit of the icovw register is cleared, with a new occurrence of a capture, the contents of ic register are overwritten by the
enhanced capture timer (ect) module enhanced capture timer modes of operation m68hc12b family ? rev. 9.0 data sheet motorola enhanced capture timer (ect) module 171 new value. in case of latching, the contents of its holding register are overwritten.  if the corresponding novwx bit of the icovw register is set, the capture register or its holding register cannot be written by an event unless they are empty (see 13.3.1 ic channels ). this will prevent the captured value to be overwritten until it is read or latched in the holding register. ic queue mode (see figure 13-2 ): when enabled (latq = 0), the main timer value is memorized in the ic register by a valid input pin transition.  if the corresponding novwx bit of the icovw register is cleared, with a new occurrence of a capture, the value of the ic register will be transferred to its holding register and the ic register memorizes the new timer value.  if the corresponding novwx bit of the icovw register is set, the capture register or its holding register cannot be written by an event unless they are empty (see 13.3.1 ic channels ). in queue mode, reads of the holding regi ster will latch the corresponding pulse accumulator value to its holding register. 13.3.2 pulse accumulators four 8-bit pulse accumulators with four 8-bit holding registers are associated with the four ic buffered channels. see figure 13-3 . a pulse accumulator counts the number of active edges at the input of its channel. the user can prevent 8-bit pulse accumulators from counting further than $ff by pacmx control bit in input control system control register (icsys). in this case, a value of $ff means that 255 counts or more have occurred. each pair of pulse accumulators can be used as a 16-bit pulse accumulator. see figure 13-4 . for more information on the two modes of operation for the pulse accumulators, see 13.3.2.1 pulse accumulator latch mode and 13.3.2.2 pulse accumulator queue mode . 13.3.2.1 pulse accumulator latch mode the value of the pulse accumulator is transferred to its holding register when the modulus down-counter reaches zero, a write $0000 to the modulus counter, or when the force latch control bit iclat is written. at the same time, the pulse accumulator is cleared. 13.3.2.2 pulse accumulator queue mode when queue mode is enabled, reads of an input capture holding register will transfer the contents of the associated pulse accumulator to its holding register. at the same time, the pulse accumulator is cleared.
enhanced capture timer (ect) module data sheet m68hc12b family ? rev. 9.0 172 enhanced capture timer (ect) module motorola figure 13-1. timer block diagram in latch mode 16 bit main timer pt1 comparator tc0h hold pt0 pt3 pt2 pt4 pt5 pt6 pt7 edg0 edg1 edg2 edg3 mux prescaler m clock 16-bit load register 16-bit modulus 0 reset edg0 edg1 edg2 edg4 edg5 edg3 edg6 edg7 1, 2, ..., 128 1, 4, 8, 16 16-bit free-running latch underflow main timer prescaler tc0 capture/compare pin delay p clock tc1h hold tc2h hold tc3h hold mux mux mux pa0h hold pac0 0 reset pa1h hold pac1 0 reset pa2h hold pac2 0 reset pa3h hold pac3 write $0000 to modulus iclat, latq, bufen (force latch) latq (mdc latch down counter logic pin logic pin logic pin logic pin logic pin logic pin logic pin logic counter delay counter delay counter delay counter register comparator tc1 capture/compare register register register register register register register register register comparator tc2 capture/compare register comparator tc3 capture/compare register comparator tc4 capture/compare register comparator tc5 capture/compare register comparator tc6 capture/compare register comparator tc7 capture/compare register counter enable)
enhanced capture timer (ect) module enhanced capture timer modes of operation m68hc12b family ? rev. 9.0 data sheet motorola enhanced capture timer (ect) module 173 figure 13-2. timer block diagram in queue mode 16 bit main timer pt1 comparator tc0h hold pt0 pt3 pt2 pt4 pt5 pt6 pt7 edg0 edg1 edg2 edg3 mux prescaler m clock 16-bit load register 16-bit modulus 0 reset edg0 edg1 edg2 edg4 edg5 edg3 edg6 edg7 1, 2, ..., 128 1, 4, 8, 16 16-bit free-running latch0 main timer prescaler tc0 capture/compare pin delay p clock mux mux mux pa0h hold pac0 0 reset pac1 0 reset pac2 0 reset pac3 latch1 latch3 latch2 down counter logic pin logic pin logic pin logic pin logic pin logic pin logic pin logic counter delay counter delay counter delay counter register comparator tc1 capture/compare register comparator tc2 capture/compare register comparator tc3 capture/compare register comparator tc4 capture/compare register comparator tc5 capture/compare register comparator tc6 capture/compare register comparator tc7 capture/compare register register tc1h hold register tc2h hold register tc3h hold register register pa3h hold register pa2h hold register pa1h hold register latq , bufen (queue mode) read tc3h hold register read tc2h hold register read tc1h hold register read tc0h hold register
enhanced capture timer (ect) module data sheet m68hc12b family ? rev. 9.0 174 enhanced capture timer (ect) module motorola figure 13-3. 8-bit pulse accumulators block diagram host cpu data bus pt0 load holding register and reset pulse accumulator 0 0 edg3 edg2 edg1 edg0 edge detector delay counter interrupt interrupt pt1 edge detector delay counter pt2 edge detector delay counter pt3 edge detector delay counter 8-bit pac0 (pacn0) pa0h holding 0 8-bit pac1 (pacn1) pa1h holding 0 8-bit pac2 (pacn2) pa2h holding 0 8-bit pac3 (pacn3) pa3h holding register register register register
enhanced capture timer (ect) module enhanced capture timer modes of operation m68hc12b family ? rev. 9.0 data sheet motorola enhanced capture timer (ect) module 175 figure 13-4. 16-bit pulse accumulators block diagram 13.3.3 modulus down-counter the modulus down-counter can be used as a timebase to generate a periodic interrupt. it can also be used to latch the values of the ic registers and the pulse accumulators to their holding registers. the action of latching can be programmed to be periodic or only once. edge detector 8-bit pac2 intermodule bus 8-bit pac3 pt7 pt0 m clock divide by 64 clock select clk0 clk1 4:1 mux timclk paclk paclk / 256 paclk / 65536 prescaled clock from timer (timer clock) interrupt mux (pamod) edge detector paca delay counter 8-bit pac0 8-bit pac1 interrupt pacb (pacn3) (pacn2) (pacn1) (pacn0)
enhanced capture timer (ect) module data sheet m68hc12b family ? rev. 9.0 176 enhanced capture timer (ect) module motorola 13.4 timer registers input/output pins default to general-purpose input/output (i/o) lines until an internal function which uses that pin is specific ally enabled. the timer overrides the state of the ddr to force the i/o state of each associated port line when an output compare using a port line is enabled. in these cases, the data direction bits will have no effect on these lines. when a pin is assigned to output an on-chip peripheral function, writing to this portt bit does not affect the pin. the data is stored in an internal latch such that if the pin becomes available for general- purpose output, the driven level will be the last value written to the portt bit. 13.4.1 timer input capture/output compare select register read: anytime write: anytime ios[7:0] ? input capture or output compare channel configuration bits 0 = the corresponding channel ac ts as an input capture. 1 = the corresponding channel acts as an output compare. 13.4.2 timer compare force register read: anytime but, will always return $00 (1 state is transient). write: anytime foc[7:0] ? force output compare action bits for channel 7?0 a write to this register with the corresponding data bit(s) set causes the action which is programmed for output compare ?n? to occur immediately. the action taken is the same as if a successful comparison had just taken place with the tcn register except the interrupt flag does not get set. address: $0080 bit 7654321bit 0 read: ios7 ios6 ios5 ios4 ios3 ios2 ios1 ios0 write: reset:00000000 figure 13-5. timer input capture/output compare select register (tios) address: $0081 bit 7654321bit 0 read: foc7 foc6 foc5 foc4 foc3 foc2 foc1 foc0 write: reset:00000000 figure 13-6. timer compare force register (cforc)
enhanced capture timer (ect) module timer registers m68hc12b family ? rev. 9.0 data sheet motorola enhanced capture timer (ect) module 177 13.4.3 output compare 7 mask register read: anytime write: anytime oc7m[7:0] bits the bits of oc7m correspond bit-for-bit with the timer port (portt) bits. setting the oc7mn will set the corresponding port to be an output port regardless of the state of the ddrtn bit, when the corres ponding tiosn bit is set to be an output compare. this does not change the state of the ddrt bits. at successful oc7, for each bit that is set in oc7m, the corresponding data bit oc7d is stored to the corresponding bit of the timer port. see figure 13-8 . figure 13-8. block diagram for port 7 with output compare/pulse accumulator a note: oc7m has priority over output action on the timer port enabled by omn and oln bits in tctl1 and tctl2. if an oc7m bit is set, it prevents the action of corresponding om and ol bits on the selected timer port. address: $0082 bit 7654321bit 0 read: oc7m7 oc7m6 oc7m5 oc7m4 oc7m3 oc7m2 oc7m1 oc7m0 write: reset:00000000 figure 13-7. output compare 7 mask register (oc7m) pulse accumulator a pad om7 = 1 or ol7 = 1 or oc7m7 = 1 oc7
enhanced capture timer (ect) module data sheet m68hc12b family ? rev. 9.0 178 enhanced capture timer (ect) module motorola 13.4.4 output compare 7 data register read: anytime write: anytime oc7d[7:0] bits the bits of oc7d correspond bit-for-bit with the bits of the timer port (portt). when a successful oc7 compare occurs, for each bit that is set in oc7m, the corresponding data bit in oc7d is stored to the corresponding bit of the timer port. when the oc7mn bit is set, a successful oc 7 action will ove rride a successful oc[6:0] compare action during the same cycle; therefore, the ocn action taken will depend on the corresponding oc7d bit. 13.4.5 timer count registers read: anytime write: has no meaning or effect in the normal mode; only writable in special modes (smodn = 0) the 16-bit main timer is an up-counter. a full access for the counter register should take place in one clock cycle. a separate read/write for high byte and low byte will give a different result than accessing them as a word. the period of the first count after a write to the tcnt registers may be a different size because the write is not synchronized with the prescaler clock. address: $0083 bit 7654321bit 0 read: oc7d7 oc7d6 oc7d5 oc7d4 oc7d3 oc7d2 oc7d1 oc7d0 write: reset:00000000 figure 13-9. output compare 7 data register (oc7d) address: $0084 bit 7654321bit 0 read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 address: $0085 bit 7654321bit 0 read: bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 write: reset:00000000 = unimplemented figure 13-10. timer count registers (tcnt)
enhanced capture timer (ect) module timer registers m68hc12b family ? rev. 9.0 data sheet motorola enhanced capture timer (ect) module 179 13.4.6 timer system control register read: anytime write: anytime ten ? timer enable bit if for any reason the timer is not active, there is no 64 clock for the pulse accumulator since the e 64 is generated by the timer prescaler. 0 = disables the main timer, includi ng the counter; can be used for reducing power consumption 1 = allows the timer to function normally tswai ? timer module stops while in wait bit tswai also affects pulse accumulators and modulus down counters. 0 = allows the timer module to continue running during wait 1 = disables the timer module when the mcu is in wait mode. timer interrupts cannot be used to get the mcu out of wait. tsbck ? timer and modulus counter stop while in background mode bit tbsck does not stop the pulse accumulator. 0 = allows the timer and modulus counter to continue running while in background mode 1 = disables the timer and modulus counter whenever the mcu is in background mode. this is useful for emulation. tffca ? timer fast flag clear all bit 0 = allows the timer flag clearing to function normally 1 = for tflg1($8e), a read from an input capture or a write to the output compare channel ($90?$9f) causes the corresponding channel flag, cnf, to be cleared. for tflg2 ($8f), any access to the tcnt register ($84, $85) clears the tof flag. any access to the pacn3 and pacn2 registers ($a2, $a3) clears the paovf and paif flags in the paflg register ($a1). any access to the pacn1 and pacn0 registers ($a4, $a5) clears the pbovf flag in the pbflg register ($b1). this has the advantage of eliminating software overhead in a separate clear sequence. extra care is required to av oid accidental flag clearing due to unintended accesses. address: $0086 bit 7654321bit 0 read: ten tswai tsbck tffca write: reset:00000000 = unimplemented figure 13-11. timer system control register (tscr)
enhanced capture timer (ect) module data sheet m68hc12b family ? rev. 9.0 180 enhanced capture timer (ect) module motorola 13.4.7 timer control registers read: anytime write: anytime omn bits ? output mode oln bits ? output level these eight pairs of control bits are encoded to specify the output action to be taken as a result of a successful ocn compare (see table 13-1 ). when either omn or oln is 1, the pin associated with ocn becomes an output tied to ocn regardless of the state of the associated ddrt bit. note: to enable output action by omn and oln bits on the timer port, the corresponding bit in oc7m should be cleared. to operate the 16-bit pulse accumulators a and b (paca and pacb) independently of input capture or output compare 7 and 0, respectively, the user must set the corresponding bits iosn = 1, omn = 0, and oln = 0. oc7m7 or oc7m0 in the oc7m register must also be cleared. address: $0088 bit 7654321bit 0 read: om7ol7om6ol6om5ol5om4ol4 write: reset:00000000 figure 13-12. timer control register 1 (tctl1) address: $0089 bit 7654321bit 0 read: om3ol3om2ol2om1ol1om0ol0 write: reset:00000000 figure 13-13. timer control register 2 (tctl2) table 13-1. compare result output action omn oln action 0 0 timer disconnected from output pin logic 0 1 toggle ocn output line 1 0 clear ocn output line to 0 1 1 set ocn output line to 1
enhanced capture timer (ect) module timer registers m68hc12b family ? rev. 9.0 data sheet motorola enhanced capture timer (ect) module 181 read: anytime write: anytime edgnb and edgna ? input capture edge control bits these eight pairs of control bits configure the input capture edge detector circuits. see table 13-2 . address: $008a bit 7654321bit 0 read: edg7b edg7a edg6b edg6a edg5b edg5a edg4b edg4a write: reset:00000000 figure 13-14. timer control register 3 (tctl3) address: $008b bit 7654321bit 0 read: edg3b edg3a edg2b edg2a edg1b edg1a edg0b edg0a write: reset:00000000 figure 13-15. timer control register 4 (tctl4) table 13-2. edge detector circuit configuration edgnb edgna configuration 0 0 capture disabled 0 1 capture on rising edges only 1 0 capture on falling edges only 1 1 capture on any edge (rising or falling)
enhanced capture timer (ect) module data sheet m68hc12b family ? rev. 9.0 182 enhanced capture timer (ect) module motorola 13.4.8 timer interrupt mask registers read: anytime write: anytime c7i?c0i ? input capture/output compare x interrupt enable bits the bits in tmsk1 correspond bit-for-bit with the bits in the tflg1 status register. if cleared, the corresponding fl ag is disabled from causing a hardware interrupt. if set, the corresponding flag is enabled to cause a hardware interrupt. read: anytime write: anytime toi ? timer overflow interrupt enable bit 0 = interrupt inhibited 1 = hardware interrupt requested when tof flag set pupt ? timer port pullup resistor enable bit this enable bit controls pullup resistors on the timer port pins when the pins are configured as inputs. 0 = disable pullup resistor function 1 = enable pullup resistor function rdpt ? timer port drive reduction bit this bit reduces the effective output dr iver size which can reduce power supply current and generated noise depending upon pin loading. 0 = normal output drive capability 1 = enable output drive reduction function tcre ? timer counter reset enable bit this bit allows the timer counter to be reset by a successful output compare 7 event. this mode of operation is simi lar to an up-counting modulus counter. 0 = counter reset inhibited and counter runs free 1 = counter reset by a successful output compare 7 address: $008c bit 7654321bit 0 read: c7i c6i c5i c4i c3i c2i c1i c0i write: reset:00000000 figure 13-16. timer interrupt mask 1 register (tmsk1) address: $008d bit 7654321bit 0 read: toi 0 pupt rdpt tcre pr2 pr1 pr0 write: reset:00000000 figure 13-17. timer interrupt mask 2 register (tmsk2)
enhanced capture timer (ect) module timer registers m68hc12b family ? rev. 9.0 data sheet motorola enhanced capture timer (ect) module 183 note: if tc7 = $0000 and tcre = 1, tcnt will stay at $0000 continuously. if tc7 = $ffff and tcre = 1, tof will never be set when tcnt is reset from $ffff to $0000. pr2, pr1, and pr0 ? timer prescaler select bits these three bits specify the number of 2 stages that are to be inserted between the module clock and the main timer counter. see table 13-3 . the newly selected prescale factor will not take effect until the next synchronized edge where all prescale counter stages equal 0. 13.4.9 main timer interrupt flag registers read: anytime write: used in the clearing mechanism (s et bits cause corresponding bits to be cleared). writing a 0 will not affect current bit status. c7f?c0f ? input capture/output compare channel n flag tflg1 indicates when interrupt conditions have occurred. to clear a bit in the flag register, write a 1 to the bit. use of the tfmod bit in the input control system control register (icsys) register ($ab) in conjunction with the us e of the icovw register ($aa) allows a timer interrupt to be generated after capturing two values in the capture and holding registers instead of generating an interrupt for every capture. table 13-3. prescaler selection value pr2 pr1 pr0 prescale factor 0000 1 1001 2 2010 4 3011 8 4100 16 5101 32 6110 64 7111 128 address: $008e bit 7654321bit 0 read: c7f c6f c5f c4f c3f c2f c1f c0f write: reset:00000000 figure 13-18. main timer interrupt flag 1 (tflg1)
enhanced capture timer (ect) module data sheet m68hc12b family ? rev. 9.0 184 enhanced capture timer (ect) module motorola when tffca bit in tscr register is set, a read from an input capture or a write into an output compare channel ($ 90?$9f) will cause the corresponding channel flag cnf to be cleared. see figure 13-19 . figure 13-19. c3f?c0f interrupt flag setting read: anytime write: used in clearing mechanism (set bits cause corresponding bits to be cleared). any access to tcnt will clear the tflg2 register, if the tffca bit in the tscr register is set. tflg2 indicates when interrupt conditions hav e occurred. to clear a bit in the flag register, set the bit to 1. tof ? timer overflow flag tof is set when the 16-bit free-running timer overflows from $ffff to $0000. this bit is cleared automatically by a wr ite to the tflg2 register with bit 7 set. see the explanation of the tcre control bit in 13.4.8 timer interrupt mask registers .) ptn edge delay 16-bit main timer tcnh ic holding bufen ? latq ? tfmod set cnf detector counter register tcn input capture register interrupt address: $008f bit 7654321bit 0 read: tof0000000 write: reset:00000000 figure 13-20. main timer interrupt flag 2 (tflg2)
enhanced capture timer (ect) module timer registers m68hc12b family ? rev. 9.0 data sheet motorola enhanced capture timer (ect) module 185 13.4.10 timer input capture/output compare registers address: $0090?$0091 bit 7654321bit 0 read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 13-21. timer input capture/output compare register 0 (tc0) address: $0092?$0093 bit 7654321bit 0 read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 13-22. timer input capture/output compare register 1 (tc1) address: $0094?$0095 bit 7654321bit 0 read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 13-23. timer input capture/output compare register 2 (tc2)
enhanced capture timer (ect) module data sheet m68hc12b family ? rev. 9.0 186 enhanced capture timer (ect) module motorola address: $0096?$0097 bit 7654321bit 0 read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 13-24. timer input capture/output compare register 3 (tc3) address: $0098?$0099 bit 7654321bit 0 read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 13-25. timer input capture/output compare register 4 (tc4) address: $009a?$009b bit 7654321bit 0 read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 13-26. timer input capture/output compare register 5 (tc5)
enhanced capture timer (ect) module timer registers m68hc12b family ? rev. 9.0 data sheet motorola enhanced capture timer (ect) module 187 read: anytime write: anytime for output compare function depending on the tios bit for the corres ponding channel, these registers are used to latch the value of the free-running counter when a defined transition is sensed by the corresponding input capture edge detector or to trigger an output action for output compare. writes to these registers have no meaning or effect during input capture. all timer input capture/output compare registers are reset to $0000. address: $009c?$009d bit 7654321bit 0 read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 13-27. timer input capture/output compare register 6 (tc6) address: $009e?$009f bit 7654321bit 0 read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 13-28. timer input capture/output compare register 7 (tc7)
enhanced capture timer (ect) module data sheet m68hc12b family ? rev. 9.0 188 enhanced capture timer (ect) module motorola 13.4.11 16-bit pulse accumulator a control register read: anytime write: anytime sixteen-bit pulse accumulator a (paca) is formed by cascading the 8-bit pulse accumulators pac3 and pac2. when paen is set, the paca is enabled. the paca shares the input pin with ic7. paen ? pulse accumulato r a system enable bit paen is independent from ten. with time r disabled, the pulse accumulator can still function unless the pulse accumulator is disabled. 0 = 16-bit pulse accumulator a syst em disabled. eight-bit pac3 and pac2 can be enabled when their related enable bits in icpacr ($a8) are set. pulse accumulator input edge flag (paif) function is disabled. 1 = pulse accumulator a system enabled. the two 8-bit pulse accumulators, pac3 and pac2, are cascaded to form the paca 16-bit pulse accumulator. when paca in enabled, the pacn3 and pacn2 registers? contents are, respectively, the high and low byte of the paca. pa3en and pa2en control bits in icpa cr ($a8) have no effect. pulse accumulator input edge flag (paif) function is enabled. pamod ? pulse accumulator mode bit 0 = event counter mode 1 = gated time accumulation mode pedge ? pulse accumulator edge control bit for pamod bit = 0, event counter mode 0 = falling edges on pt7 pin cause the count to be incremented. 1 = rising edges on pt7 pin cause the count to be incremented. for pamod bit = 1, gated time accumulation mode 0 = pt7 input pin high enables m divided by 64 clock to pulse accumulator and the trailing falling edge on pt7 sets the paif flag. 1 = pt7 input pin low enables m divided by 64 clock to pulse accumulator and the trailing rising edge on pt7 sets the paif flag. address: $00a0 bit 7654321bit 0 read: 0 paen pamod pedge clk1 clk0 paovi pai write: reset:00000000 = unimplemented figure 13-29. 16-bit pulse accumulator a control register (pactl) pamod pedge pin action 0 0 falling edge 0 1 rising edge 1 0 divide by 64 clock enabled with pin high level 1 1 divide by 64 clock enabled with pin low level
enhanced capture timer (ect) module timer registers m68hc12b family ? rev. 9.0 data sheet motorola enhanced capture timer (ect) module 189 note: if the timer is not active (ten = 0 in tscr), there is no divide-by-64 since the e clk1 and clk0 ? clock select bits if the pulse accumulator is disabled (paen = 0), the prescaler clock from the timer is always used as an input clock to the timer counter. the change from one selected clock to the other happens imm ediately after these bits are written. paovi ? pulse accumulator a overflow interrupt enable bit 0 = interrupt inhibited 1 = interrupt requested if paovf is set pai ? pulse accumulator input interrupt enable bit 0 = interrupt inhibited 1 = interrupt requested if paif is set 13.4.12 pulse accumulator a flag register read: anytime write: anytime when the tffca bit in the tscr register is set, any access to the pacnt register will clear all the flags in the paflg register. paovf ? pulse accumulator a overflow flag set when the 16-bit pulse accumulator a overflows from $ffff to $0000 or when 8-bit pulse accumulator 3 (pac3) overflows from $ff to $00. this bit is cleared automatically by a write to the paflg register with bit 1 set. paif ? pulse accumulator input edge flag set when the selected edge is detected at the pt7 input pin. in event mode, the event edge triggers paif and, in gated time accumulation mode, the trailing edge of the gate signal at the pt7 input pi n triggers paif. this bit is cleared by a write to the paflg register with bit 0 set. any access to the pacn3 and pacn2 registers will clear all the flags in this register when tffca bit in register tscr ($86) is set. clk1 clk0 clock source 0 0 use timer prescaler clock as timer counter clock 0 1 use paclk as input to timer counter clock 1 0 use paclk/256 as timer counter clock frequency 1 1 use paclk/65,536 as timer counter clock frequency address: $00a1 bit 7654321bit 0 read: 000000paovfpaif write: reset:00000000 figure 13-30. pulse accumulator a flag register (paflg)
enhanced capture timer (ect) module data sheet m68hc12b family ? rev. 9.0 190 enhanced capture timer (ect) module motorola 13.4.13 pulse accumulators count registers read: anytime write: anytime the two 8-bit pulse accumulators, pac3 and pac2, are cascaded to form the paca 16-bit pulse accumulator. when paca in enabled (paen = 1 in pactl, $a0) the pacn3 and pacn2 registers? conten ts are, respectively, the high and low bytes of the paca. when pacn3 overflows from $ff to $00, the interrupt flag paovf in paflg ($a1) is set. full count register access should take place in one clock cycle. a separate read/write for high byte and low byte will give a different result than accessing them as a word. read: anytime write: anytime address: $00a2 bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 13-31. pulse accumulator count register 3 (pacn3) address: $00a3 bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 13-32. pulse accumulator count register 2 (pacn2) address: $00a4 bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 13-33. pulse accumulator count register 1 (pacn1) address: $00a5 bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 13-34. pulse accumulator count register 0 (pacn0)
enhanced capture timer (ect) module timer registers m68hc12b family ? rev. 9.0 data sheet motorola enhanced capture timer (ect) module 191 the two 8-bit pulse accumulators, pac1 and pac0, are cascaded to form the pacb 16-bit pulse accumulator. when pacb in enabled, (pben = 1 in pbctl, $b0) the pacn1 and pacn0 register contents are, respectively, the high and low bytes of the pacb. when pacn1 overflows from $ff to $00, the interrupt flag pbovf in pbflg ($b1) is set. full count register access should take place in one clock cycle. a separate read/write for high byte and low byte will give a different result than accessing them as a word. 13.4.14 16-bit modulus down-counter control register read: anytime write: anytime mczi ? modulus counter underflow interrupt enable bit 0 = modulus counter interrupt is disabled. 1 = modulus counter interrupt is enabled. modmc ? modulus mode enable bit 0 = the counter counts once from the value written to it and will stop at $0000. 1 = modulus mode is enabled. when the counter reaches $0000, the counter is loaded with the latest value wri tten to the modulus count register. note: for proper operation, the mcen bit should be cleared before modifying the modmc bit to reset the modulus counter to $ff. rdmcl ? read modulus down-counter load bit 0 = reads of the modulus count register will return the present value of the count register. 1 = reads of the modulus count register will return the contents of the load register. iclat ? input capture force latch action bit when input capture latch mode is enabled (latq and bufen bit in icsys ($ab) are set), writing 1 to this bit immediately forces the contents of the input capture registers tc0 to tc3 and their corresponding 8-bit pulse accumulators to be latched into the associated holding registers. the pulse accumulators will be automatically cleared when the latch action occurs. writing 0 to this bit has no effect. r ead of this bit aways will return 0. address: $00a6 bit 7654321bit 0 read: mczi modmc rdmcl iclat flmc mcen mcpr1 mcpr0 write: reset:00000000 figure 13-35. 16-bit modulus down-counter control register (mcctl)
enhanced capture timer (ect) module data sheet m68hc12b family ? rev. 9.0 192 enhanced capture timer (ect) module motorola flmc ? force load register into the modulus counter count register bit this bit is active only when the modul us down-counter is enabled (mcen = 1). writing a 1 into this bit loads the load register into the modulus counter count register. this also resets the modulus counter prescaler. writing 0 to this bit has no effect. when modmc = 0, the counter starts counting and stops at $0000. reads of this bit will return always 0. mcen ? modulus down-counter enable bit when mcen = 0, the counter is preset to $ffff. this will prevent an early interrupt flag when the modulus down-counter is enabled. 0 = modulus counter disabled. 1 = modulus counter is enabled. mcpr1 and mcpr0 ? modulus counter prescaler select bits these two bits specify the division rate of the modulus counter prescaler. the newly selected prescaler division rate will not be effective until a load of the load register into the modulus counter count register occurs. 13.4.15 16-bit modulus down-counter flag register read: anytime write: only for clearing bit 7 mczf ? modulus counter underflow interrupt flag the flag is set when the modulus down -counter reaches $0000. writing 1 to this bit clears the flag. writing 0 has no effe ct. any access to the mccnt register will clear the mczf flag in this register when tffca bit in register tscr ($86) is set. polf3?polf0 ? first input capture polarity status bits this are read-only bits. writing to these bi ts has no effect. each status bit gives the polarity of the first edge which has caused an input capture to occur after capture latch has been read. each polfx corresponds to a timer portx input. 0 = the first input capture has been caused by a falling edge. 1 = the first input capture has been caused by a rising edge. mcpr1 mcpr0 prescalar division rate 00 1 01 4 10 8 11 16 address: $00a7 bit 7654321bit 0 read: mczf 0 0 0 polf3 polf2 polf1 polf0 write: reset:00000000 figure 13-36. 16-bit modulus down-counter flag register (mcflg)
enhanced capture timer (ect) module timer registers m68hc12b family ? rev. 9.0 data sheet motorola enhanced capture timer (ect) module 193 13.4.16 input control pulse accumulators control register read: anytime write: anytime the 8-bit pulse accumulators, pac3 and pac2, can be enabled only if paen in patcl ($a0) is cleared. if paen is se t, pa3en and pa2en have no effect. the 8-bit pulse accumulators, pac1 and pac0, can be enabled only if pben in pbtcl ($b0) is cleared. if pben is set, pa1en and pa0en have no effect. paxen ? 8-bit pulse accumulator x enable bits 0 = 8-bit pulse accumulator disabled 1 = 8-bit pulse accumulator enabled 13.4.17 delay counter control register read: anytime write: anytime if enabled, after detection of a valid edge on input capture pin, the delay counter counts the pre-selected number of p clock (module clock) cycles, then it will generate a pulse on its output. the pulse is generated only if the level of input signal, after the preset delay, is the opposit e of the level before the transition.this will avoid reaction to narrow input pulses. after counting, the counter will be cleared automatically. delay between two active edges of the input signal period should be longer than the selected counter delay. dlyx ? delay counter select bits address: $00a8 bit 7654321bit 0 read: 0000pa3enpa2enpa1enpa0en write: reset:00000000 figure 13-37. input control pulse accumulators control register (icpacr) address: $00a9 bit 7654321bit 0 read: 000000dly1dly0 write: reset:00000000 figure 13-38. delay counter control register (dlyct) dly1 dly0 delay 0 0 disabled (bypassed) 0 1 256 p clock cycles 1 0 512 p clock cycles 1 1 1024 p clock cycles
enhanced capture timer (ect) module data sheet m68hc12b family ? rev. 9.0 194 enhanced capture timer (ect) module motorola 13.4.18 input control overwrite register read: anytime write: anytime an ic register is empty when it has been read or latched into the holding register. a holding register is empty when it has been read. novwx ? no input capture overwrite bits 0 = the contents of the related capture register or holding register can be overwritten when a new input capture or latch occurs. 1 = the related capture register or holding register cannot be written by an event unless they are empty (see 13.3.1 ic channels ). this will prevent the captured value to be overwritten until it is read or latched in the holding register. 13.4.19 input control system control register read: anytime write: may be written once (smodn = 1). writes are always permitted when smodn = 0. shxy ? share input action of input capture channels x and y bits 0 = normal operation 1 = the channel input x causes the same action on the channel y. the port pin x and the corresponding edge detector is used to be active on the channel y. tfmod ? timer flag-setting mode bit use of the tfmod bit in the icsys register ($ab) in conjunction with the use of the icovw register ($aa) allows a timer interrupt to be generated after capturing two values in the capture and holding registers instead of generating an interrupt for every capture. address: $00aa bit 7654321bit 0 read: novw7 novw6 novw5 novw4 novw3 novw2 novw1 novw0 write: reset:00000000 figure 13-39. input control overwrite register (icovw) address: $00ab bit 7654321bit 0 read: sh37 sh26 sh15 sh04 tfmod pacmx bufen latq write: reset:00000000 figure 13-40. input control system control register (icsys)
enhanced capture timer (ect) module timer registers m68hc12b family ? rev. 9.0 data sheet motorola enhanced capture timer (ect) module 195 by setting tfmod in queue mode, when novw bit is set and the corresponding capture and holding registers are empti ed, an input capture event will first update the related input capture register with the main timer contents. at the next event, the tcn data is transferred to the tcnh register, the tcn is updated, and the cnf interrupt flag is set. see figure 13-19 . in all other input capture cases, the interrupt flag is set by a valid external event on ptn. 0 = the timer flags c3f?c0f in tflg1 ($8e) are set when a valid input capture transition on the corresponding port pin occurs. 1 = if in queue mode (bufen = 1 and latq = 0), the timer flags c3f?c0f in tflg1 ($8e) are set only when a latch on the corresponding holding register occurs. if the queue mode is not engaged, the timer flags c3f?c0f are set the same way as for tfmod = 0. pacmx ? 8-bit pulse accumulators maximum count bit 0 = normal operation. when the 8-bi t pulse accumulator has reached the value $ff, with the next active edge, it will be incremented to $00. 1 = when the 8-bit pulse accumulator has reached the value $ff, it will not be incremented further. the value $ff indicates a count of 255 or more. bufen ? ic buffer enable bit 0 = input capture and pulse accumula tor holding registers are disabled. 1 = input capture and pulse accumulator holding registers are enabled. the latching mode is defined by latq control bit. writing a 1 into iclat bit in mcctl ($a6) when latq is set, will produce latching of input capture and pulse accumulator registers into their holding registers. latq ? input control latch or queue mode enable bit the bufen control bit should be set to enable the ic and pulse accumulators? holding registers. otherwise, la tq latching modes are disabled. writing one into iclat bit in mcctl ($a6), when latq and bufen are set will produce latching of input capture and pu lse accumulators registers into their holding registers. 0 = queue mode of input capture is enabled. the main timer value is memorized in the ic register by a va lid input pin transition. with a new occurrence of a capture, the value of the ic register will be transferred to its holding register and the ic register memorizes the new timer value. 1 = latch mode is enabled. latching function occurs when modulus down-counter reaches 0 or a 0 is written into the count register mccnt (see 13.3.1.2 buffered ic channels ). with a latching event the contents of ic registers and 8-bit pulse accumulators are transferred to their holding registers. the 8-bit pulse accumulators are cleared.
enhanced capture timer (ect) module data sheet m68hc12b family ? rev. 9.0 196 enhanced capture timer (ect) module motorola 13.4.20 timer test register read: anytime write: only in special mode (smod = 1) tcbyp ? main timer divider chain bypass bit 0 = normal operation 1 = for testing only. the 16-bit free-runni ng timer counter is divided into two 8-bit halves and the prescaler is by passed. the clock drives both halves directly. when the high byte of time r counter tcnt ($84) overflows from $ff to $00, the tof flag in tflg2 ($8f) will be set. 13.4.21 timer port data register read: anytime (input return pin level; outputs return data register contents) write: data stored in an internal latch (drives pins only if configured for output) since the output compare 7 register (oc7) shares pins with the pulse accumulator input, the only way for the pulse accumulator to receive an independent input from oc7 is by setting both om7 and ol7 to be 0, and also oc7m7 in oc7m register to be 0. oc7 can still reset the counter if enabled while pt7 is used as an input to the pulse accumulator. portt can be read anytime. when configured as an input, a read will return the pin level. when configured as an output, a read will return the latched output data. note: writes do not change pin state when the pin is configured for timer output. the minimum pulse width for pulse accumulator input should always be greater than the width of two module clocks due to input synchronizer circuitry. the minimum pulse width for the input capture should always be greater than the width of two module clocks due to input synchronizer circuitry. address: $00ad bit 7654321bit 0 read:000000tcbyppcbyp (1) write: reset:00000000 = unimplemented 1. available only on mc68hc912b32 devices. figure 13-41. timer test register (timtst) address: $00ae bit 7654321bit 0 read: pt7 pt6 pt5 pt4 pt3 pt2 pt1 pt0 write: timer: i/0c7 i/oc6 i/oc5 i/oc4 i/oc3 i/oc2 i/oc1 i/oc0 reset:00000000 figure 13-42. timer port data register (portt)
enhanced capture timer (ect) module timer registers m68hc12b family ? rev. 9.0 data sheet motorola enhanced capture timer (ect) module 197 13.4.22 data direction register for timer port read: anytime write: anytime ddt[7:0] ? data direction bits for timer port the timer forces the i/o state to be an output for each timer port line associated with an enabled output compare. in these cases the data direction bits will not be changed, but have no effect on the di rection of these pi ns. the ddrt will revert to controlling the i/o direction of a pin when the associated timer output compare is disabled. input captur es do not override the ddrt settings. 0 = configures the corresponding i/o pin for input only 1 = configures the corresponding i/o pin for output 13.4.23 16-bit pulse accumulator b control register read: anytime write: anytime sixteen-bit pulse accumulator b (pacb) is formed by cascading the 8-bit pulse accumulators pac1 and pac0. when pben is set, the pacb is enabled. the pacb shares the input pin with ic0. pben ? pulse accumulator b system enable bit pben is independent from ten. with time r disabled, the pulse accumulator can still function unless pulse accumulator is disabled. 0 = 16-bit pulse accumulator system disabled. eight-bit pac1 and pac0 can be enabled when their related enable bits in icpacr ($a8) are set. 1 = pulse accumulator b system enabled. the two 8-bit pulse accumulators pac1 and pac0 are cascaded to form the pacb 16-bit pulse accumulator. when pacb is enabled, the pacn1 and pacn0 register contents are, respectively, the high and low byte of the pacb. pa1en and pa0en control bits in icpacr ($a8) have no effect. address: $00af bit 7654321bit 0 read: ddt7 ddt6 ddt5 ddt4 ddt3 ddt2 ddt1 ddt0 write: reset:00000000 figure 13-43. data direction register for timer port (ddrt) address: $00b0 bit 7654321bit 0 read: 0 pben 0000pbov0 write: reset:00000000 figure 13-44. 16-bit pulse accumulator b control register (pbctl)
enhanced capture timer (ect) module data sheet m68hc12b family ? rev. 9.0 198 enhanced capture timer (ect) module motorola pbovi ? pulse accumulator b overflow interrupt enable bit 0 = interrupt inhibited 1 = interrupt requested if pbovf is set 13.4.24 pulse accumulator b flag register  read:anytime  write:anytime pbovf ? pulse accumulator b overflow flag this bit is set when the 16-bit pulse accumulator b overflows from $ffff to $0000 or when 8-bit pulse accumulator 1 (pac1) overflows from $ff to $00. this bit is cleared by a write to the pbflg register with bit 1 set. any access to the pacn1 and pacn0 registers will clear the pbovf flag in this register when tffca bit in register tscr ($86) is set. 13.4.25 8-bit pulse accumulators holding registers address: $00b1 bit 7654321bit 0 read: 000000pbovf0 write: reset:00000000 figure 13-45. pulse accumulator b flag register (pbflg) address: $00b2 bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 13-46. 8-bit pulse accumulator holding register 3 (pa3h) address: $00b3 bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 13-47. 8-bit pulse accumulator holding register 2 (pa2h) address: $00b4 bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 13-48. 8-bit pulse accumulator holding register 1 (pa1h)
enhanced capture timer (ect) module timer registers m68hc12b family ? rev. 9.0 data sheet motorola enhanced capture timer (ect) module 199 read: anytime write: anytime these registers are used to latch the value of the corresponding pulse accumulator when the related bits in register icpacr ($a8) are enabled (see 13.3.2 pulse accumulators ). 13.4.26 modulus down-counter count registers read: anytime write: anytime a full access for the counter register should take place in one clock cycle. a separate read/write for high byte and low byte will give different results than accessing them as a word. if the rdmcl bi t in mcctl register is cleared, reads of the mccnt register will return the present value of the count register. if the rdmcl bit is set, reads of the mccnt will return the contents of the load register. if a $0000 is written into mccnt and modul us counter while latq and bufen in icsys ($ab) register are set, the input capture and pulse accumulator registers will be latched. with a $0000 write to the mccnt, the modulus counter will stay at 0 and does not set the mczf flag in mcflg register. if modulus mode is enabled (modmc = 1), a write to this address will update the load register with the value written to it. the count register will not be updated with address: $00b5 bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 13-49. 8-bit pulse accumulator holding register 0 (pa0h) address: $00b6 bit 7654321bit 0 read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:11111111 address: $00b7 bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:11111111 figure 13-50. modulus down-co unter count registers (mccnt)
enhanced capture timer (ect) module data sheet m68hc12b family ? rev. 9.0 200 enhanced capture timer (ect) module motorola the new value until the next counter underflow. the flmc bit in mcctl ($a6) can be used to immediately update the count register with the new value if an immediate load is desired. if modulus mode is not enabled (modmc = 0), a write to this address will clear the prescaler and will immediately update the counter register with the value written to it and down-counts once to $0000. 13.4.27 timer input capture holding registers address: $00b8 bit 7654321bit 0 read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 address: $00b9 bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 13-51. timer input capture holding register 0 (tc0h) address: $00ba bit 7654321bit 0 read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 address: $00bb bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 13-52. timer input capture holding register 1 (tc1h)
enhanced capture timer (ect) module timer registers m68hc12b family ? rev. 9.0 data sheet motorola enhanced capture timer (ect) module 201 read: anytime write: has no effect these registers are used to latch the value of the input capture registers tc0?tc3. the corresponding iosx bits in tios ($80) should be cleared (see 13.3.1 ic channels ). address: $00bc bit 7654321bit 0 read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 address: $00bd bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 13-53. timer input capture holding register 2 (tc2h) address: $00be bit 7654321bit 0 read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset:00000000 address: $00bf bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:00000000 figure 13-54. timer input capture holding register 3 (tc3h)
enhanced capture timer (ect) module data sheet m68hc12b family ? rev. 9.0 202 enhanced capture timer (ect) module motorola 13.5 timer and modulus counter operation in different modes stop timer and modulus counter are off since clocks are stopped. bgdm timer and modulus counter keep on ru nning unless bit 5, tsbck, of tscr is set to 1. see 13.4.6 timer system control register . wait counters keep on running, unless the ts wai bit in tscr is set to 1. see 13.4.6 timer system control register . normal timer and modulus counter keep on running, unless the ten bit in tscr and mcen in mcctl, respectively, are cleared. see 13.4.6 timer system control register and 13.4.14 16-bit modulus down-counter control register . ten = 0 all 16-bit timer operations are stopped; can only access the registers mcen = 0 modulus counter is stopped. paen = 1 sixteen-bit pulse accumulator a is active. paen = 0 eight-bit pulse accumulators 3 and 2 can be enabled. see 13.4.16 input control pulse accumulators control register . pben = 1 sixteen-bit pulse accumulator b is active. pben = 0 eight-bit pulse accumulators 1 and 0 can be enabled. see 13.4.16 input control pulse accumulators control register .
m68hc12b family ? rev. 9.0 data sheet motorola serial interface 203 data sheet ? m68hc12b family section 14. serial interface 14.1 introduction the serial interface of the mcu consis ts of two independent serial input/output (i/o) subsystems:  serial communication interface (sci)  serial peripheral interface (spi) each serial pin shares function with the general-purpose port pins of port s. the sci is an nrz (non-return to zero) type system that is compatible with standard rs-232 systems. the sci system has a single-wire operation mode which allows the unused pin to be avai lable as general-purpose i/o. the spi subsystem, which is compatible with the m68hc11 spi, includes new features such as ss output and bidirectional mode. figure 14-1. serial interface block diagram sci i/o spi ddrs/ioctlr port s i/o drivers serial interface ps0 ps1 ps2 ps3 ps4 ps5 ps6 ps7 rxd txd miso/siso mosi/momi sck cs /ss i/o i/o
serial interface data sheet m68hc12b family ? rev. 9.0 204 serial interface motorola 14.2 serial communi cation interface (sci) the sci on the mcu is an nrz format (one start, eight or nine data, and one stop bit) asynchronous communication system with independent internal baud rate generation circuitry and an sci transmitte r and receiver. it can be configured for eight or nine data bits (one of which may be designated as a parity bit, odd or even). if enabled, parity is generated in hardware for transmitted and received data. receiver parity errors are flagged in hardware. the baud rate generator is based on a modulus counter, allowing flexibilit y in choosing baud rates. there is a receiver wakeup feature, an idle line detec t feature, a loop-back mode, and various error detection features. two port pins provide the external interface for the transmitted data (txd) and the received data (rxd). see figure 14-2 . 14.2.1 data format the serial data format requires these conditions:  an idle-line in the high state before transmission or reception of a message  a start bit (logic 0), transmitted or rece ived, that indicates the start of each character  data that is transmitted or receiv ed least significant bit (lsb) first  a stop bit (logic 1) used to indicate the end of a frame a frame consists of:  a start bit  a character of eight or nine data bits  a stop bit a break is defined as the transmission or reception of a logic 0 for one frame or more. this sci supports hardware parity for transmit and receive.
serial interface serial communication interface (sci) m68hc12b family ? rev. 9.0 data sheet motorola serial interface 205 figure 14-2. serial communications interface block diagram rx baud rate tx baud rate mclk divider 10-11 bit shift reg msb txd buffer/sc0drl txmtr control sc0cr2/sci ctl 2 sc0cr1/sci ctl 1 sc0sr1/int status data recovery 10-11 bit shift reg rxd buffer/sc0drl sc0bd/select lsb rxd txd pin control / ddrs / port s wakeup logic sc0cr1/sci ctl 1 sc0sr1/int status sc0cr2/sci ctl 2 int request logic msb lsb int request logic sci receiver sci transmitter data bus parity detect parity generator to internal logic baud rate clock ps0 ps1
serial interface data sheet m68hc12b family ? rev. 9.0 206 serial interface motorola 14.2.2 sci baud rate generation the basis of the sci baud rate generator is a 13-bit modulus counter. this counter gives the generator the flexibility necessary to achieve a reasonable level of independence from the cpu operating frequency and still be able to produce standard baud rates with a minimal amount of error. the clock source for the generator comes from the p clock. 14.2.3 sci register descriptions control and data registers for the sci subsystem are described here. the memory address indicated for each register is the def ault address that is in use after reset. the entire 512-byte register block can be mapped to any 2-kbyte boundary within the standard 64-kbyte address space. 14.2.3.1 sci baud rate control register table 14-1. baud rate generation desired sci baud rate br divisor for p = 4.0 mhz br divisor for p = 8.0 mhz 110 2273 4545 300 833 1667 600 417 833 1200 208 417 2400 104 208 4800 52 104 9600 26 52 14,400 17 35 19,200 13 26 38,400 ? 13 address: $00c0 bit 7654321bit 0 read: btst bspl brld sbr12 sbr11 sbr10 sbr9 sbr8 write: reset:00000000 figure 14-3. sci baud rate control register (sc0bdh) address: $00c1 bit 7654321bit 0 read: sbr7 sbr6 sbr5 sbr4 sbr3 sbr2 sbr1 sbr0 write: reset:00000100 figure 14-4. sci baud rate control register (sc0bdl)
serial interface serial communication interface (sci) m68hc12b family ? rev. 9.0 data sheet motorola serial interface 207 read: anytime write: sbr12?sbr0 anytime; low-order byte must be written for change to take effect ? sbr15?sbr13 only in special modes sc0bdh and sc0bdl are considered together as a 16-bit baud rate control register. the value in sbr12?sbr0 determines the baud rate of the sci. the desired baud rate is determined by the following formula: which is equivalent to: br is the value written to bits sbr12?sbr0 to establish the baud rate. note: the baud rate generator is disabled until the te or re bit in sc0cr2 register is set for the first time after reset and/or the baud rate generator is disabled when sbr12?sbr0 = 0. btst ? reserved for test function bspl ? reserved for test function brld ? reserved for test function 14.2.3.2 sci control register 1 read: anytime write: anytime loops ? sci loop mode/si ngle-wire mode enable bit 0 = sci transmit and receive sections operate normally. 1 = sci receive section is disconnect ed from the rxd pin and the rxd pin is available as general-purpose i/o. the receiver input is determined by the rsrc bit. the transmitter output is controlled by the associated ddrs bit. both the transmitter and the receiver must be enabled to use the loop or the single-wire mode. sci baud rate mclk 16 br --------------------- = br mclk 16 sci baud rate ------------------------------------------------- - = address: $00c2 bit 7654321bit 0 read: loops woms rsrc m wake ilt pe pt write: reset:00000000 figure 14-5. sci control register 1 (sc0cr1)
serial interface data sheet m68hc12b family ? rev. 9.0 208 serial interface motorola if the ddrs bit associated with the txd pin is set during the loops = 1, the txd pin outputs the sci waveform. if the ddrs bit associated with the txd pin is clear during the loops = 1, the txd pin becomes high (idle line state) for rsrc = 0 and high impedance for rsrc = 1. refer to table 14-2 . woms ? wired-or mode for serial pins this bit controls the two pins (txd and rxd) associated with the scix section. 0 = pins operate in a normal mode with both high and low drive capability. to affect the rxd bit, that bit would hav e to be configured as an output (via dds0/2) which is the single-wire case when using the sci. woms bit still affects general-purpose output on txd and rxd pins when scix is not using these pins. 1 = each pin operates in an open drain fashion if that pin is declared as an output . rsrc ? receiver source bit when loops = 1, the rsrc bit determines the internal feedback path for the receiver. 0 = receiver input connected to the transmitter internally (not txd pin) 1 = receiver input connected to the txd pin m ? mode bit (select character format) 0 = one start, eight data, one stop bit 1 = one start, eight data, ninth data, one stop bit wake ? wakeup by address mark/idle bit 0 = wakeup by idle line recognition 1 = wakeup by address mark (last data bit set) table 14-2. loop mode functions loops rsrc dds1 woms function of port s bit 1/3 0 x x x normal operations 1000/1 loop mode without txd output (txd = high impedance) 1 0 1 0 loop mode with txd output (cmos) 1 0 1 1 loop mode with txd output (open-drain) 110 x single-wire mode without txd output (pin is used as receiver input only, txd = high impedance) 111 0 single-wire mode with txd output (the output is also fed back to receiver input, cmos.) 111 1 single wire mode for the receiving and transmitting (open-drain)
serial interface serial communication interface (sci) m68hc12b family ? rev. 9.0 data sheet motorola serial interface 209 ilt ? idle line type bit this bit determines which of two types of idle line detection is used by the sci receiver. 0 = short idle line mode enabled 1 = long idle line mode detected in short mode, the sci circuitry begins counting 1s in the search for the idle line condition immediately after the start bit. this means that the stop bit and any bits that were 1s before the stop bit could be counted in that string of 1s, resulting in earlier recognition of an idle line. in long mode, the sci circuitry does not begin counting 1s in the search for the idle line condition until a stop bit is rece ived. therefore, the last byte?s stop bit and preceding 1 bits do not affect how quickly an idle line condition can be detected. pe ? parity enable bit 0 = parity disabled 1 = parity enabled pt ? parity type bit if parity is enabled, this bit determines even or odd parity for both the receiver and the transmitter. an even number of 1s in the data character causes the parity bit to be 0 and an odd number of 1s causes the parity bit to be 1. 0 = even parity selected 1 = odd parity selected 14.2.3.3 sci control register 2 read: anytime write: anytime tie ? transmit interrupt enable bit 0 = tdre interrupts disabled 1 = sci interrupt requested when tdre status flag is set tcie ? transmit complete interrupt enable bit 0 = tc interrupts disabled 1 = sci interrupt requested when tc status flag is set rie ? receiver interrupt enable bit 0 = rdrf and or interrupts disabled 1 = sci interrupt requested when rdrf status flag or or status flag is set address: $00c3 bit 7654321bit 0 read: tie tcie rie ilie te re rwu sbk write: reset:00000000 figure 14-6. sci control register 2 (sc0cr2)
serial interface data sheet m68hc12b family ? rev. 9.0 210 serial interface motorola ilie ? idle line interrupt enable bit 0 = idle interrupts disabled 1 = sci interrupt requested when idle status flag is set te ? transmitter enable bit 0 = transmitter disabled 1 = sci transmit logic is enabled and the txd pin (port s bit 1) is dedicated to the transmitter. the te bit can be used to queue an idle preamble. re ? receiver enable bit 0 = receiver disabled 1 = enables the sci receive circuitry rwu ? receiver wakeup control bit 0 = normal sci receiver 1 = enables the wakeup function and inhibits further receiver interrupts. normally, hardware wakes the receiver by automatically clearing this bit. sbk ? send break bit 0 = break generator off 1 = generate a break code, at least 10 or 11 contiguous 0s. as long as sbk remains set, the trans mitter sends 0s. whe n sbk is changed to 0, the current frame of all 0s is fi nished before the txd line goes to the idle state. if sbk is toggled on and off, the transmitter sends only 10 (or 11) 0s and then reverts to mark idle or sending data. 14.2.3.4 sci status register 1 read: anytime; used in auto clearing mechanism write: has no meaning or effect the bits in these registers are set by va rious conditions in the sci hardware and are cleared automatically by special acknowledge sequences. the receive related flag bits in sc0sr1 (rdrf, idle, or, nf, fe, and pf) are all cleared by a read of the sc0sr1 register followed by a read of the transmit/receive data register low byte. however, only those bits which were set when sc0sr1 was read will be cleared by the subsequent read of the transmit/receive data register low byte. the address: $00c4 bit 7654321bit 0 read: tdre tc rdrf idle or nf fe pf write: reset:11000000 = unimplemented figure 14-7. sci status register 1 (sc0sr1)
serial interface serial communication interface (sci) m68hc12b family ? rev. 9.0 data sheet motorola serial interface 211 transmit related bits in sc0sr1 (tdre and tc) are cleared by a read of the sc0sr1 register followed by a write to th e transmit/receive data register low byte. tdre ? transmit data register empty flag new data is not transmitted unless sc0sr1 is read before writing to the transmit data register. reset sets this bit. 0 = sc0dr busy 1 = any byte in the transmit data regi ster is transferred to the serial shift register so new data may now be written to the transmit data register. tc ? transmit complete flag flag is set when the transmitter is idle (no data, preamble, or break transmission in progress). clear by reading sc0sr1 with tc set and then writing to sc0dr. 0 = transmitter busy 1 = transmitter idle rdrf ? receive data register full flag once cleared, idle is not set again until the rxd line has been active and becomes idle again. rdrf is set if a receiv ed character is ready to be read from sc0dr. clear the rdrf flag by reading sc0sr1 with rdrf set and then reading sc0dr. 0 = sc0dr empty 1 = sc0dr full idle ? idle line detected flag receiver idle line is detected (the receipt of a minimum of 10 or 11 consecutive 1s). this bit is not set by the idle line condition when the rwu bit is set. once cleared, idle is not set again until after rdrf has been set (after the line has been active and becomes idle again). 0 = rxd line active 1 = rxd line idle or ? overrun error flag new byte is ready to be transferred from the receive shift register to the receive data register and the receive data register is already full (rdrf bit is set). data transfer is inhibited until this bit is cleared. 0 = no overrun 1 = overrun detected nf ? noise error flag set during the same cycle as the rdrf bit but not set in the case of an overrun (or). 0 = unanimous decision 1 = noise on a valid start bit, any of the data bits, or on the stop bit fe ? framing error flag set when a 0 is detected where a stop bit was expected. clear the fe flag by reading sc0sr1 with fe set and then reading sc0dr. 0 = stop bit detected 1 = zero detected rather than a stop bit
serial interface data sheet m68hc12b family ? rev. 9.0 212 serial interface motorola pf ? parity error flag indicates if received data?s parity matches parity bit. this feature is active only when parity is enabled. the type of parity tested for is determined by the pt (parity type) bit in sc0cr1. 0 = parity correct 1 = incorrect parity detected 14.2.3.5 sci status register 2 read: anytime write: has no meaning or effect raf ? receiver active flag this bit is controlled by the receiver front end. it is set during the rt1 time period of the start bit search. it is cleared when an idle state is detected or when the receiver circuitry detects a false star t bit (generally due to noise or baud rate mismatch). 0 = character is not being received. 1 = character is being received. address: $00c5 bit 7654321bit 0 read:0000000raf write: reset:00000000 = unimplemented figure 14-8. sci status register 2 (sc0sr2)
serial interface serial communication interface (sci) m68hc12b family ? rev. 9.0 data sheet motorola serial interface 213 14.2.3.6 sci data register read: anytime write: varies on a bit by bit basis r8 ? receive bit 8 write has no meaning or effect. this bit is the ninth serial data bit re ceived when the sci system is configured for 9-data-bit operation. t8 ? transmit bit 8 write anytime. this bit is the ninth serial data bit trans mitted when the sci system is configured for 9-data-bit operation. when using 9-bit data format, this bit does not have to be written for each data word. the same va lue is transmitted as the ninth bit until this bit is rewritten. r7t7?r0t0 ? receive/transmit data bits 7 to 0 reads access the eight bits of the read-only sci receive data register (rdr). writes access the eight bits of the writ e-only sci transmit data register (tdr). sc0drl and sc0drh form the 9-bit data word for the sci. if the sci is being used with a 7- or 8-bit data word, only sc0drl needs to be accessed. if a 9-bit format is used, the upper register shoul d be written first to ensure that it is transferred to the transmitter shift register with the lower register. address: $00c6 bit 7654321bit 0 read: r8 t8 000000 write: reset:uu000000 = unimplemented u = unaffected figure 14-9. sci data register high (sc0drh) address: $00c7 bit 7654321bit 0 read: r7t7 r6t6 r5t5 r4t4 r3t3 r2t2 r1t1 r0t0 write: reset: unaffected by reset figure 14-10. sci data register low (sc0drl)
serial interface data sheet m68hc12b family ? rev. 9.0 214 serial interface motorola 14.3 serial peripher al interface (spi) the serial peripheral interface (spi) allows the mcu to communicate synchronously with peripheral devices and other microprocessors. the spi system in the mcu can operate as a master or as a slave. the spi is also capable of interprocessor communications in a multiple master system. when the spi is enabled, all pins that are defined by the configuration as inputs will be inputs regardless of the state of the ddrs bits for those pins. all pins that are defined as spi outputs will be outputs only if the ddrs bits for those pins are set. any spi output whose corresponding ddrs bit is cleared can be used as a general-purpose input. a bidirectional serial pin is possible using the ddrs as the direction control. figure 14-11. serial peripheral interface block diagram pin control logic 8-bit shift register read data buffer shift control logic clock logic spi control sp0sr spi status register sp0dr spi data register spif wcol modf divider select sp0br spi baud rate register 2 4 8 16 32 64 128 256 spi interrupt internal bus mcu p clock same as e rate s m m s m s spr2 spr1 spr0 request spie spe mstr cpol cpha lsbf lsbf pups rds swom spc0 ssoe spe clock mstr swom miso ps4 sck ps6 ss ps7 mosi ps5 sp0cr1 spi control register 1 sp0cr2 spi control register 2
serial interface serial peripheral interface (spi) m68hc12b family ? rev. 9.0 data sheet motorola serial interface 215 14.3.1 spi baud rate generation the p clock is input to a divider series and the resulting spi clock rate may be selected to be p divided by 2, 4, 8, 16, 32, 64, 128, or 256. three bits in the sp0br register control the spi clock rate. this baud rate generator is activated only when spi is in the master mode and serial transfe r is taking place. ot herwise, this divider is disabled to save power. 14.3.2 spi operation in the spi system, the 8-bit data register in the master and the 8-bit data register in the slave are linked to form a distributed 16-bit register. when a data transfer operation is performed, this 16- bit register is serially sh ifted eight bit positions by the sck clock from the master so the data is effectively exchanged between the master and the slave. data written to the sp0dr register of the master becomes the output data for the slave and data read from the sp0dr register of the master after a transfer operation is the input data from the slave. a clock phase control bit (cpha) and a clock polarity control bit (cpol) in the spi control register 1 (sp0cr1) select one of four possible clock formats to be used by the spi system. the cpol bit simply selects non-inverted or inverted clock. the cpha bit is used to accommodate two fundam entally different protocols by shifting the clock by one half cycle or no phase shift. figure 14-12. spi clock format 0 (cpha = 0) t l begin end sck (cpol = 0) sample i change o transfer sck (cpol = 1) msb first (lsbf = 0) : lsb first (lsbf = 1) : msb lsb lsb msb bit 5 bit 2 bit 6 bit 1 bit 4 bit 3 bit 3 bit 4 bit 2 bit 5 bit 1 bit 6 change o mosi pin miso pin mosi/miso t t f or t t , t l , t l minimum 1/2 sck t i t l sel ss (o) sel ss (i) master only
serial interface data sheet m68hc12b family ? rev. 9.0 216 serial interface motorola figure 14-13. spi clock format 1 (cpha = 1) 14.3.3 ss output available in master mode only, ss output is enabled with the ssoe bit in the sp0cr1 register if the corresponding ddrs bit is set. the ss output pin is connected to the ss input pin of the exter nal slave device. the ss output automatically goes low for each transmission to select the external device and it goes high during each idling stat e to deselect external devices. 14.3.4 bidirectional mode (momi or siso) in bidirectional mode, the spi uses only one serial data pin for external device interface. the mstr bit decides which pin to be used. the mosi pin becomes a serial data i/o (momi) pin for the master mode, and the miso pin becomes a serial data i/o (siso) pin for the slave mode. th e direction of each se rial i/o pin depends on the corresponding ddrs bit. t l t t for t t , t l , t l minimum 1/2 sck t i t l begin end sck (cpol = 0) sample i change o sel ss (o) transfer sck (cpol = 1) msb first (lsbf= 0) : lsb first (lsbf = 1) : msb lsb lsb msb bit 5 bit 2 bit 6 bit 1 bit 4 bit 3 bit 3 bit 4 bit 2 bit 5 bit 1 bit 6 change o sel ss (i) mosi pin miso pin master only mosi/miso table 14-3. ss output selection dds7 ssoe master mode slave mode 00ss input with modf feature ss input 01reserved ss input 1 0 general-purpose output ss input 11ss output ss input
serial interface serial peripheral interface (spi) m68hc12b family ? rev. 9.0 data sheet motorola serial interface 217 figure 14-14. normal mode and bidirectional mode 14.3.5 spi register descriptions control and data registers for the spi subsystem are described in this section. the memory address indicated for each register is the default address that is in use after reset. the entire 512-byte register block can be mapped to any 2-kbyte boundary within the standard 64-kbyte address space. for more information, refer to section 5. operating modes and resource mapping . 14.3.5.1 spi control register 1 read: anytime write: anytime spie ? spi interrupt enable bit 0 = spi interrupts are inhibited. 1 = hardware interrupt sequence is requested each time the spif or modf status flag is set. spe ? spi system enable bit 0 = spi internal hardware is initialized and spi system is in a low-power disabled state. 1 = ps4?ps7 are dedicated to the spi function. when modf is set, spe always reads 0. sp0cr1 must be written as part of a mode fault recovery sequence. when spe = 1 master mode mstr = 1 slave mode mstr = 0 normal mode spc0 = 0 swom enables open-drain output. swom enables open-drain output. bidirectional mode spc0 = 1 swom enables open-drain output. ps4 becomes gpio . swom enables open-drain output. ps5 becomes gpio. spi mo mi dds5 serial out serial in spi si so serial in serial out dds4 spi momi ps4 dds5 serial out serial in spi ps5 siso dds4 serial in serial out address: $00d0 bit 7654321bit 0 read: spie spe swom mstr cpol cpha ssoe lsbf write: reset:00000100 figure 14-15. spi control register 1 (sp0cr1)
serial interface data sheet m68hc12b family ? rev. 9.0 218 serial interface motorola swom ? port s wired-or mode bit controls not only spi output pins but also the general-purpose output pins (ps4?ps7) which are not used by spi. 0 = spi and/or ps4?ps7 output buffers operate normally. 1 = spi and/or ps4?ps7 output buffers behave as open-drain outputs. mstr ? spi master/slave mode select bit 0 = slave mode 1 = master mode cpol and cpha ? spi clock polarity, clock phase bits these two bits are used to specify the cl ock format to be used in spi operations. when the clock polarity bit is cleared and data is not being transferred, the sck pin of the master device is low. when cpol is set, sck idles high. see figure 14-12 and figure 14-13 . ssoe ? slave select output enable bit the ss output feature is enabled only in master mode by asserting the ssoe and dds7. lsbf ? spi lsb first enable bit 0 = data is transferred most-s ignificant bit (msb) first. 1 = data is transferred least- significant bit (lsb) first. normally, data is transferred msb first. th is bit does not affect the position of the msb and lsb in the data register. reads and writes of the data register always have msb in bit 7. 14.3.5.2 spi control register 2 read: anytime write: anytime pups ? pullup port s enable bit 0 = no internal pullups on port s 1 = all port s input pins have an active pullup device. if a pin is programmed as output, the pullup dev ice becomes inactive. rds ? reduce drive of port s bit 0 = port s output drivers operate normally. 1 = all port s output pins have reduced drive capability for lower power and less noise. spc0 ? serial pin control 0 bit this bit decides serial pin configurations with mstr control bit. address: $00d1 bit 7654321bit 0 read:0000 pups rds 0 spc0 write: reset:00001000 = unimplemented figure 14-16. spi control register 2 (sp0cr2)
serial interface serial peripheral interface (spi) m68hc12b family ? rev. 9.0 data sheet motorola serial interface 219 14.3.5.3 spi baud rate register read: anytime write: anytime at reset, e clock divided by 2 is selected. spr2?spr0 ? spi clock (sck) rate select bits these bits are used to specify the spi clock rate. table 14-4. serial pin control pin mode spc0 (1) mstr miso (2) mosi (3) sck (4) ss (5) #1 normal 0 0 slave out slave in sck in ss in #2 1 master in master out sck out ss i/o #3 bidirectional 1 0 slave i/o general-purposei/o sck in ss in #4 1 general-purposei/o master i/o sck out ss i/o 1. the serial pin control 0 bit enables bidirectional configurations. 2. slave output is enabled if dds4 = 1, ss = 0, and mstr = 0. (#1, #3) 3. master output is enabled if dds5 = 1 and mstr = 1. (#2, #4) 4. sck output is enabled if dds6 = 1 and mstr = 1. (#2, #4) 5. ss output is enabled if dds7 = 1, sso e = 1, and mstr = 1. (#2, #4) address: $00d2 bit 7654321bit 0 read:00000 spr2 spr1 spr0 write: reset:00000000 = unimplemented figure 14-17. spi baud rate register (sp0br) table 14-5. spi clock rate selection spr2 spr1 spr0 e clock divisor frequency at e clock = 4 mhz frequency at e clock = 8 mhz 0 0 0 2 2.0 mhz 4.0 mhz 0 0 1 4 1.0 mhz 2.0 mhz 0 1 0 8 500 khz 1.0 mhz 0 1 1 16 250 khz 500 khz 1 0 0 32 125 khz 250 khz 1 0 1 64 62.5 khz 125 khz 1 1 0 128 31.3 khz 62.5 khz 1 1 1 256 15.6 khz 31.3 khz
serial interface data sheet m68hc12b family ? rev. 9.0 220 serial interface motorola 14.3.5.4 spi status register read: anytime write: has no meaning or effect spif ? spi interrupt request bit spif is set after the eighth sck cycle in a data transfer, and it is cleared by reading the sp0sr register (with spif set) followed by an access (read or write) to the spi data register. wcol ? write collision status flag the mcu write is disabled to avoid writing over the data being transferred. no interrupt is generated because the error status flag can be read upon completion of the transfer that was in prog ress at the time of the error. this bit is cleared automatically by a read of the sp0sr (with wcol set) followed by an access (read or write) to the sp0dr register. 0 = no write collision 1 = indicates that a serial transfer was in progress when the mcu tried to write new data into the sp0dr data register modf ? spi mode error interrupt status flag this bit is set automatically by spi hard ware, if the mstr control bit is set and the slave select input pin becomes 0. this condition is not permitted in normal operation. in the case where ddrs bit 7 is set, the ps7 pin is a general-purpose output pin or ss output pin rather than being dedicated as the ss input for the spi system. in this special case, the m ode fault function is inhibited and modf remains cleared. this flag is cleared automatically by a read of the sp0sr (with modf set) followed by a write to the sp0cr1 register. address: $00d3 bit 7654321bit 0 read:spifwcol0modf0000 write: reset:00000000 = unimplemented figure 14-18. spi status register (sp0sr)
serial interface port s m68hc12b family ? rev. 9.0 data sheet motorola serial interface 221 14.3.5.5 spi data register read: anytime; normally, only after spif flag set write: anytime; see wcol write collision flag in 14.3.5.4 spi status register this 8-bit register is both the input and output register for spi data. reads of this register are double buffered but writes cause data to bewritten directly into the serial shifter. in the spi system, the 8-bit data register in the master and the 8-bit data register in the slave are linked by the mosi and miso wires to form a distributed 16-bit register. when a data transfer operation is performed, this 16-bit register is serially shifted eight bit posit ions by the sck clock from the master so the data is exchanged effectively between the master and the slave. note: some slave devices are simple and either accept data from the master without returning data to the master or pass data to the master without requiring data from the master. 14.4 port s in all modes, port s bits ps7?ps0 can be used for either general-purpose i/o or with the sci and spi subsystems. during reset, port s pins are configured as high-impedance inputs (ddrs is cleared). 14.4.1 port s data register read: anytime; inputs return pin level; outputs return pin driver input level write: data stored in internal latch; drives pins only if configured for output; does not change pin state when pin configured for spi or sci output port s shares function with the on-chip serial systems, spi0 and sci0. address: $00d5 bit 7654321bit 0 read: bit 7bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset: unaffected by reset figure 14-19. spi data register (sp0dr) address: $00d6 bit 7654321bit 0 read: ps7 ps6 ps5 ps4 ps3 ps2 ps1 ps0 write: pin function ss cs sck mosi momi miso siso ? ? txd0 rxd0 reset: after reset all bits configured as general-purpose inputs figure 14-20. port s data register (ports)
serial interface data sheet m68hc12b family ? rev. 9.0 222 serial interface motorola 14.4.2 port s data direction register read: anytime write: anytime after reset, all general-purpose i/o are configured for input only. 0 = configure the correspondi ng i/o pin for input only. 1 = configure the corresponding i/o pin for output. dds0 ? data direction for port s bit 0 if the sci receiver is configured for 2-wire sci operation, corresponding port s pins are input regardless of the state of these bits. dds1 ? data direction for port s bit 1 if the sci transmitter is configured for 2-wire sci operation, corresponding port s pins are output regardless of the state of these bits. dds2 and dds3 ? data direction for port s bit 2 and bit 3 these bits are for general-purpose only. dds6?dds4 ? data direction for port s bits 6?4 if the spi is enabled and expects the corresponding port s pin to be an input, it will be an input regardless of the state of the ddrs bit. if the spi is enabled and expects the bit to be an output, it will be an output only if the ddrs bit is set. dds7 ? data direction for port s bit 7 in spi slave mode, dds7 has no meaning or effect; the ps7 pin is dedicated as the ss input. in spi master mode, dds7 determines whether ps7 is an error detect input to the spi or a general-purpose or slave select output line. address: $00d7 bit 7654321bit 0 read: dds7 dds6 dds5 dds4 dds3 dds2 dds1 dds0 write: reset:00000000 figure 14-21. port s data direction register (ddrs)
serial interface port s m68hc12b family ? rev. 9.0 data sheet motorola serial interface 223 14.4.3 pullup and reduced drive register for port s read: anytime write: anytime rdps2 ? reduce drive of ps7?ps4 0 = port s output drivers for bits 7?4 operate normally. 1 = port s output pins for bits 7?4 have reduced drive capability for lower power and less noise. rdps1 ? reduce drive of ps3 and ps2 0 = port s output drivers for bits 3 and 2 operate normally. 1 = port s output pins for bits 3 and 2 have reduced drive capability for lower power and less noise. rdps0 ? reduce drive of ps1 and ps0 0 = port s output drivers for bits 1 and 0 operate normally. 1 = port s output pins for bits 1 and 0 have reduced drive capability for lower power and less noise. pups2 ? pullup port s enable ps7?ps4 0 = no internal pullups on port s bits 7?4. 1 = port s input pins for bits 7?4 have an active pullup device. if a pin is programmed as output, the pullup device becomes inactive. pups1 ? pullup port s enable ps3 and ps2 bit 0 = no internal pullups on port s bits 3 and 2 1 = port s input pins for bits 3 and 2 have an active pullup device. if a pin is programmed as output, the pullup device becomes inactive. pups0 ? pullup port s enable ps1 and ps0 bit 0 = no internal pullups on port s bits 1 and 0 1 = port s input pins for bits 1 and 0 have an active pullup device. if a pin is programmed as output, the pullup device becomes inactive. address: $00db bit 7654321bit 0 read: 0 rdps2 rdps1 rdps0 0 pups2 pups1 pups0 write: reset:00000000 = unimplemented figure 14-22. pullup and reduced drive register for port s (purds)
serial interface data sheet m68hc12b family ? rev. 9.0 224 serial interface motorola 14.5 serial character transmission using the sci code is intended to use sci1 to serially transmit characters using polling to the lcd display on the udlp1 board: when the transmission data register is empty a flag will get set, which is telling us that sc1dr is ready so we can write another byte. the transmission is performed at a baud rate of 9600. since the sci1 is only being used for transmit data, the data regi ster will not be used bidirectionally for received data. 14.5.1 equipment for this exercise, use the m68hc912b32evb emulation board. 14.5.2 code listing note: a comment line is deliminted by a semi-c olon. if there is no code before comment, an ?;? must be placed in the first colu mn to avoid assembly errors. include 'equates.asm' ; equates for registers ; user variables ; bit equates ; ---------------------------------------------------------------------- ; main program ; ---------------------------------------------------------------------- org $7000 ; 16k on-board ram, user code data area, ; ; start main program at $4000 main: bsr init ; subroutine to initialize sci0 registers bsr trans ; subroutine to start transmission done: bra done ; always branch to done, convenient for breakpoint ; ---------------------------------------------------------------------- ; subroutine init: ; ---------------------------------------------------------------------- init: tpa ; transfer ccr to a accumulator oraa #$10 ; ored a with #$10 to set i bit tap ; transfer a to ccr movb #$34,sc1bdl ; set baud =9600, in sci1 baud rate reg. movb #$00,sc1cr1 ; initialize for 8-bit data format, ; ; loop mode and parity disabled,(sc1cr1) movb #$08,sc1cr2 ; set for no ints, and transmitter enabled(sc1cr2) ldaa sc1sr1 ; 1st step to clear tdre flag: read sc1sr1 std sc1drh ; 2nd step to clear tdre flag: write sc1dr register ldx #data ; use x as a pointer to data. rts ; return from subroutine
serial interface synchronous character transmission using the spi m68hc12b family ? rev. 9.0 data sheet motorola serial interface 225 ; ---------------------------------------------------------------------- ; transmit subroutine ; ---------------------------------------------------------------------- trans: brclr sc1sr1,#$80, trans ; wait for tdre flag movb 1,x+,sc1drl ; transmit character, increment x pointer cpx #eot ; detect if last character has been transmitted bne trans ; if last char. not equal to "eot", branch to trans rts ; else transmission complete, return from subroutine ; ---------------------------------------------------------------------- ; table : data to be transmitted ; ---------------------------------------------------------------------- data: dc.b 'motorola hc12 banner - june, 1999' dc.b $0d,$0a ; return (cr) ,line feed (lf) dc.b 'scottsdale, arizona' dc.b $0d,$0a ; return (cr) ,line feed (lf) eot: dc.b $04 ; byte used to test end of data = eot end ; end of program 14.6 synchronous character transmission using the spi this program is intended to communicate with the hc11 on the udlp1 board. it utilizes the spi to transmit synchronously characters in a string to be displayed on the lcd display. the program must configure the spi as a master, and non-interrupt driven. the slave peripheral is chip-selected with the ss line at low voltage level. between 8 bit transfers the ss line is held high. also the clock idles low and takes data on the rising clock edges. the serial clock is set not to exceed 100 khz baud rate. 14.6.1 equipment for this exercise, use the m68hc912b32evb emulation board. 14.6.2 code listing note: a comment line is deliminted by a semi-c olon. if there is no code before comment, an ?;? must be placed in the first colu mn to avoid assembly errors. include 'equates.asm' ;equates for all registers ; user variables ; bit equates ; ---------------------------------------------------------------------- ; main program ; ---------------------------------------------------------------------- org $7000 ; 16k on-board ram, user code data area, ; ; start main program at $7000 main: bsr init ; subroutine to initialize spi registers bsr transmit ; subroutine to start transmission finish: bra finis ; finished transmitting all data
serial interface data sheet m68hc12b family ? rev. 9.0 226 serial interface motorola ; ---------------------------------------------------------------------- ;* subroutine init: ; ---------------------------------------------------------------------- init: bset ports,#$80 ; set ss line high to prevent glitch movb #$e0,ddrs ; configure port s input/ouput levels ; ; mosi, sck, ss* = ouput, miso=input movb #$07,sp0br ; select serial clock baud rate < 100 khz movb #$12,sp0cr1 ; configure spi(sp0cr1): no spi interrupts, ; ; mstr=1, cpol=0, cpha=0 movb #$08,sp0cr2 ; config. ports output drivers to operate normally, ; ; and with active pull-up devices. ldx #data ; use x register as pointer to first character ldaa sp0sr ; 1st step to clear spif flag, read sp0sr ldaa sp0dr ; 2nd step to clear spif flag, access sp0dr bset sp0cr1,#$40 ; enable the spi (spe=1) rts ; return from subroutine ; ---------------------------------------------------------------------- ;* transmit subroutine ; ---------------------------------------------------------------------- transmit: ldaa 1,x+ ; load acc. with "new" character to send, inc x beq done ; detect if last character(0) has been transmitted ; ; if last char. branch to done, else bclr ports,#$80 ; assert ss line to start x-misssion. staa sp0dr ; load data into data reg.,x-mit. ; ; it is also the 2nd step to clear spif flag. flag: brclr sp0sr,#$80,flag ;wait for flag. bset ports,#$80 ; disassert ss line. bra transmit ; continue sending characters, branch to transmit. done: rts ; return from subroutine ; ---------------------------------------------------------------------- ; table of data to be transmitted ; ---------------------------------------------------------------------- data: dc.b 'motorola' dc.b $0d,$0a ; return (cr) ,line feed (lf) eot: dc.b $00 ; byte used to test end of data = eot end ; end of program
m68hc12b family ? rev. 9.0 data sheet motorola byte data link communications (bdlc) 227 data sheet ? m68hc12b family section 15. byte data li nk communications (bdlc) 15.1 introduction the byte data link communica tions module (bdlc) provi des access to an external serial communication multiplex bus, operating accord ing to the sae j1850 protocol. 15.2 features features of the bdlc module include:  sae j1850 class b data communications network interface compatible and iso compatible for low-speed (< 125 kbps) serial data communications in automotive applications  10.4 kbps variable pulse width (vpw) bit format  digital noise filter  collision detection  hardware cyclical redundancy check generation and checking  two power-saving modes with automatic wakeup on network activity  polling or cpu interrupts  block mode receive and transmit  4x receive mode, 41.6 kbps  digital loopback mode  analog loopback mode  in-frame response (ifr) types 0, 1, 2, and 3 note: familiarity with the sae standard j1850 class b data communication network interface specification is recommended befor e proceeding. first-time users of the motorola bdlc should obtain the byte data link controller reference manual, motorola document order number bdlcrm/ad.
byte data link communications (bdlc) data sheet m68hc12b family ? rev. 9.0 228 byte data link communications (bdlc) motorola 15.3 functional description figure 15-1 shows the organization of the bdlc module. the cpu interface contains the software addressable regist ers and provides the link between the cpu and the buffers. the buffers provide storage for data received and data to be transmitted onto the j1850 bus. the prot ocol handler is responsible for the encoding and decoding of data bits and special message symbols during transmission and reception. the mux in terface provides the link between the bdlc digital section and the analog physica l interface. the wave shaping, driving, and digitizing of data is performed by the physical interface. use of the bdlc module in messag e networking fully implements the sae standard j1850 class b data communication network interface specification. figure 15-1. bdlc block diagram cpu interface to j1850 bus mux interface protocol handler physical interface to cpu bdlc
byte data link communications (bdlc) bdlc operating modes m68hc12b family ? rev. 9.0 data sheet motorola byte data link communications (bdlc) 229 15.4 bdlc o perating modes the bdlc has five main modes of operation which interact with the power supplies, pins, and rest of the mcu as shown in figure 15-2 . figure 15-2. bdlc operating modes state diagram 15.4.1 power off mode for guaranteed bdlc operation, this mode is entered from reset mode when the bdlc supply voltage, v dd , drops below its minimum specified value. the bdlc is placed in reset mode by low-voltage reset (lvr) before being powered down. in power off mode, the pin input and output specifications are not guaranteed. 15.4.2 reset mode this mode is entered from power off mode when the bdlc supply voltage, v dd , rises above its minimum specified value (v dd ?10%) and an mcu reset source is asserted. the internal mcu reset must be asserted while powering up the bdlc or an unknown state is entered and correct operation cannot be guaranteed. reset mode is also entered from any other m ode when any reset source is asserted. v dd > v dd (minimum) and power off reset bdlc stop run v dd v dd (minimum) stop instruction or from any mode bdlc wait network activity or wait instruction and wcm = 1 wait instruction and wcm = 0 any mcu reset source asserted no mcu reset source asserted any mcu reset source asserted network activity or other mcu wakeup other mcu wakeup (cop, illaddr, pu, reset, lvr, por)
byte data link communications (bdlc) data sheet m68hc12b family ? rev. 9.0 230 byte data link communications (bdlc) motorola in reset mode, the internal bdlc voltage references are operative, v dd is supplied to the internal circuits which are held in their reset state, and the internal bdlc system clock is running. registers assume their reset condition. because outputs are held in their programmed reset state, inputs and network activity are ignored. 15.4.3 run mode this mode is entered from reset mode after all mcu reset sources are no longer asserted. run mode is entered from the bd lc wait mode when activity is sensed on the j1850 bus. run mode is entered from the bdlc stop mode when network activity is sensed, although messages are not received properly until the clocks have stabilized and the cpu is also in run mode. in this mode, normal network operation takes place. ensure that all bdlc transmissions have ceased before exiting this mode. 15.5 power-conserving modes the bdlc has three power-conserving modes: 1. bdlc wait and cpu wait mode 2. bdlc stop and cpu wait mode 3. bdlc stop and cpu stop mode depending upon the logic level of the wcm bit in bdlc control register 1 (bcr1), the bdlc enters a power-conserving mode when the cpu executes the stop or wait instruction. when a power-conserving mode is entered, any activity on the j1850 network causes the bdlc to exit low-power mode. when exiting from bdlc stop mode, the bdlc generates an unmaskable interrupt of the cpu. this wakeup interrupt state is reflected in the bdlc state vector register (bsvr) and encoded as the highest priority interrupt. wait mode or stop mode does not reset the bdlc registers upon bdlc wakeup. to disengage a bdlc node from receiving j1850 traffic:  verify all bsvr flags are clear.  do not load the bdr.  set the aloop bit (after placing the analog transceiver into loopback mode) or dloop bit in bcr2. the bdlc can then be put into wait mode or stop mode and does not wake up with j1850 traffic.
byte data link communications (bdlc) power-conserving modes m68hc12b family ? rev. 9.0 data sheet motorola byte data link communications (bdlc) 231 depending upon which low-power mode instruction the cpu executes and which mode the bdlc enters, the message which wakes up the bdlc (and the cpu) may not be received correctly. three pos sibilities are described here. these descriptions apply regardless of whether the bdlc is in normal or 4x mode when the stop or wait instruction is executed. 15.5.1 bdlc wait and cpu wait mode this power-saving mode is entered automatically from run mode when the wcm bit in bcr1 register is cleared followed by a cpu wait instruction. in bdlc wait mode, the bdlc cannot drive data. a subsequent j1850 network rising edge wakes up the bdlc. in this mode, the bdlc internal clocks continue to run as do the mcu clocks. the first passive-to-active transition on the j1850 network generates a cpu interrupt request by the bdlc which wakes up the bdlc and cpu. the bdlc correctly receives the entire message which generated the cpu interrupt request. note: ensure that all transmissions are complete or aborted prior to putting the bdlc into wait mode (wcm = 0 in bcr1). 15.5.2 bdlc stop and cpu wait mode this power-conserving mode is entered automatically from run mode when the wcm bit in the bcr1 register is set foll owed by a cpu wait instruction. this is the lowest-power mode that the bdlc can enter. in this mode:  the bdlc internal clocks are stopped.  the cpu internal clocks continue to run.  the bdlc awaits j1850 network activity. the first passive-to-active transition on the j1850 network generates a non-maskable ($20) cpu interrupt request by the bdlc, allowing the cpu to restart the bdlc internal clocks. to correctly receive future j1850 wakeup traffic, users must read an eof (end of frame) in the bsvr prior to placing the bd lc into stop mode (wcm = 1). then, the new message which wakes up the bdlc from the bdlc stop mode and the cpu from the cpu wait mode, is received correctly. note: ensure that all transmissions are complete or aborted prior to putting the bdlc into stop mode (wcm = 1 in bcr1).
byte data link communications (bdlc) data sheet m68hc12b family ? rev. 9.0 232 byte data link communications (bdlc) motorola 15.5.3 bdlc stop and cpu stop mode this power-conserving mode is entered automatically from run mode when the wcm bit in the bcr1 register is set foll owed by a cpu stop instruction. this is the lowest-power mode that the bdlc can enter. in this mode:  the bdlc internal clocks are stopped.  the cpu internal clocks are stopped.  the bdlc awaits j1850 network activity. the first passive-to-active transition on the j1850 network generates a non-maskable ($20) cpu interrupt request by the bdlc, allowing the cpu clocks to restart and the bdlc internal clocks to restart. therefore, the new message which wakes up the bdlc from the bdlc stop mode and the cpu from the cpu wait mode are not received correctly. this is due primarily to the time required for the mcu?s oscillator to stabilize before th e clocks can be applied internally to the other mcu modules, including the bdlc. note: ensure that all transmissions are complete or aborted prior to putting the bdlc into stop mode (wcm = 1 in bcr1). 15.6 loopback modes two loopback modes are used to determine the source of bus faults. 15.6.0.1 digital loopback mode when a bus fault has been detected, the digital loopback mode is used to determine if the fault condition is caused by failure in the node?s internal circuits or elsewhere in the network, including the node?s analog physical interface. in this mode, the transmit digital output pin (bdtxd) and the receive digital input pin (bdrxd) of the digital interface ar e disconnected from the analog physical interface and tied together to allow the digital portion of the bdlc to transmit and receive its own messages without driving the j1850 bus. 15.6.0.2 analog loopback mode analog loopback mode is used to determi ne if a bus fault has been caused by a failure in the node?s off-chip analog transceiver or elsewhere in the network. the bdlc analog loopback mode does not modify the digital transmit or receive functions of the bdlc. it does, however, ensure that once analog loopback mode is exited, the bdlc waits for an idle bus condition before participation in network communication resumes. if the off-chip analog transceiver has a loopback mode, it usually causes the input to the output drive stage to be looped back into the receiver, allowing the node to receive messages it has transmitted without driving the j1850 bus. in this mode, the output to the j1850 bus typically is high
byte data link communications (bdlc) bdlc mux interface m68hc12b family ? rev. 9.0 data sheet motorola byte data link communications (bdlc) 233 impedance. this allows the communication path through the analog transceiver to be tested without interfering with network activity. using the bdlc analog loopback mode in conjunction with the analog transceiver?s loopback mode ensures that, once the off-chip analog transceiver ha s exited loopback mode, the bdlc does not begin communicating before a known condition exists on the j1850 bus. 15.7 bdlc mux interface the mux (multiplex) interface is responsible for bit encoding/decoding and digital noise filtering between the protocol handler and the physical interface. 15.7.1 rx digital filter the receiver section of the bdlc includes a digital low-pass filter to remove narrow noise pulses from the incoming message. an outline of the digital filter is shown in figure 15-3 . figure 15-3. bdlc rx digital filter block diagram 15.7.1.1 operation the clock for the digital filter is provided by the mux interface clock (see f bdlc parameter in table 15-2 ). at each positive edge of the clock signal, the current state of the receiver physical interface (bdrxd) signal is sampled. the bdrxd signal state is used to determine whether the counter should increment or decrement at the next negat ive edge of the clock signal. the counter increments if the input data sample is high but decrements if the input sample is low. therefore, the counter progresses either up toward 15 if, on average, the bdrxd signal remains high or progresses down toward 0 if, on average, the bdrxd signal remains low. 4-bit up/down counter data latch up/down out filtered rx data out mux input sync dq rx data from physical interface clock (bdrxd) dq interface
byte data link communications (bdlc) data sheet m68hc12b family ? rev. 9.0 234 byte data link communications (bdlc) motorola when the counter eventually reaches the valu e 15, the digital filter decides that the condition of the bdrxd signal is at a stable logic level 1 and the data latch is set, causing the filtered rx data signal to become a logic level 1. furthermore, the counter is prevented from overflowing and can be decremented only from this state. alternatively, should the counter eventually reach the value 0, the digital filter decides that the condition of the bdrxd signal is at a stable logic level 0 and the data latch is reset, causing the filtered rx data signal to become a logic level 0. furthermore, the counter is prevented from underflowing and can be incremented only from this state. the data latch retains its value until the counter next reaches the opposite end point, signifying a definite transition of the signal. 15.7.1.2 performance the performance of the digital filter is best described in the time domain rather than the frequency domain. if the signal on the bdrxd signal transitions , there is a delay before that transition appears at the filtered rx data output signal . this delay is between 15 and 16 clock periods, depending on where the transition occurs with respect to the sampling points. this filter delay must be taken into account when performing message arbitration. for example, if the frequency of the mux interface clock (f bdlc ) is 1.0486 mhz, then the period (t bdlc ) is 954 ns and the maximum filter delay in the absence of noise is 15.259 s. the effect of random noise on the bdrxd signal depends on the characteristics of the noise itself. narrow noise pulses on the bdrxd signal is ignored completely if they are shorter than the filter delay. this provides a degree of low pass filtering. if noise occurs during a symbol transition, the detection of that transition can be delayed by an amount equal to the length of the noise burst. this is a reflection of the uncertainty of where the transition is actually occurring within the noise. noise pulses that are wider than the filter delay, but narrower than the shortest allowable symbol length, are detected by t he next stage of the bdlc?s receiver as an invalid symbol. noise pulses that are longer than the shortest allowable symbol length are detected normally as an invalid symbol or as invalid data when the frame?s crc is checked.
byte data link communications (bdlc) bdlc mux interface m68hc12b family ? rev. 9.0 data sheet motorola byte data link communications (bdlc) 235 15.7.2 j1850 frame format all messages transmitted on the j1850 bus are structured using the format shown in figure 15-4 . j1850 states that each message has a maximum length of 101 pwm bit times or 12 vpw bytes, excluding sof, eod, nb, and eof, with each byte transmitted most significant bit (msb) first. all vpw symbol lengths in the following descriptions are typical values at a 10.4-kbps bit rate. 15.7.2.1 sof ? start-of-frame symbol all messages transmitted onto the j1850 bus must begin with a long-active 200 s period sof symbol. this indicates the st art of a new message transmission. the sof symbol is not used in the crc calculation. 15.7.2.2 data ? in-message data bytes the data bytes contained in the message include the message priority/type, message id byte (typically, the physical ad dress of the responder), and any actual data being transmitted to the receiving node. the message format used by the bdlc is similar to the 3-byte consolid ated header message format outlined by the sae j1850 document. see sae j1850 ? class b data communications network interface specification for more information about 1- and 3-byte headers. messages transmitted by the bdlc onto t he j1850 bus must contain at least one data byte, and, therefore, can be as s hort as one data byte and one crc byte. each data byte in the message is eight bi ts in length and is transmitted msb (most significant bit) to lsb (least significant bit). 15.7.2.3 crc ? cyclical redundancy check byte this byte is used by the receiver(s) of each message to determine if any errors have occurred during the tr ansmission of the message. t he bdlc calculates the crc byte and appends it onto any messages transmitted onto the j1850 bus. it also performs crc detection on any me ssages it receives from the j1850 bus. data e o d optional i f s idle sof priority (data0) message id (data1) data n crc n b ifr eof idle figure 15-4. j1850 bus message format (vpw)
byte data link communications (bdlc) data sheet m68hc12b family ? rev. 9.0 236 byte data link communications (bdlc) motorola crc generation uses the divisor polynomial x 8 + x 4 + x 3 + x 2 + 1. the remainder polynomial initially is set to all 1s. each byte in the message after the start-of-frame (sof) symbol is processed serially th rough the crc generation circuitry. the one?s complement of the remainder then becomes the 8-bit crc byte, which is appended to the message after the data bytes, in msb-to-lsb order. when receiving a message, the bdlc uses the same divisor polynomial. all data bytes, excluding the sof a nd end-of-data symbols (eod) but including the crc byte, are used to check the crc. if the message is error free, the remainder polynomial equals x 7 + x 6 + x 2 = $c4, regardless of the data contained in the message. if the calculated crc does not equal $c4, the bd lc recognizes this as a crc error and sets the crc error flag in the bsvr. 15.7.2.4 eod ? end-of-data symbol the eod symbol is a long 200- s passive period on the j1850 bus used to signify to any recipients of a message that the transmission by the originator has completed. no flag is set upon reception of the eod symbol. 15.7.2.5 ifr ? in-frame response bytes the ifr section of the j1850 message format is optional. users desiring further definition of in-frame response should review the sae j1850 ? class b data communications network interface specification. 15.7.2.6 eof ? end-of-frame symbol this symbol is a long 280- s passive period on the j1850 bus and is longer than an end-of-data (eod) symbol, which signif ies the end of a message. since an eof symbol is longer than a 200- s eod symbol, if no response is transmitted after an eod symbol, it becomes an eof, and the message is assumed to be completed. the eof flag is set upon receiving the eof symbol. 15.7.2.7 ifs ? interframe separation symbol the ifs symbol is a 20- s passive period on the j1850 bus which allows proper synchronization between nodes during cont inuous message transmission. the ifs symbol is transmitted by a node after the completion of the end-of-frame (eof) period and, therefore, is seen as a 300- s passive period. when the last byte of a message has been transmitted onto the j1850 bus and the eof symbol time has expired, all nodes then must wait for the ifs symbol time to expire before transmitting a start-of-fra me (sof) symbol, marking the beginning of another message.
byte data link communications (bdlc) bdlc mux interface m68hc12b family ? rev. 9.0 data sheet motorola byte data link communications (bdlc) 237 however, if the bdlc is waiting for th e ifs period to expire before beginning a transmission and a rising edge is detected before the ifs time has expired, it synchronizes internally to that edge. a rising edge may occur during the ifs per iod because of varying clock tolerances and loading of the j1850 bus, c ausing different nodes to observe the completion of the ifs period at different times. to allow for individual clock tolerances, receivers must synchronize to any sof occurring during an ifs period. 15.7.2.8 break ? break the bdlc cannot transmit a break symbol. if the bdlc is transmitting at the time a break is detected, it treats the break as if a transmission error had occurred and halts transmission. if the bdlc detects a break symbol whil e receiving a message, it treats the break as a reception error and sets the invalid symbol flag in the bsvr, also ignoring the frame it was receiving. if while receiving a message in 4x mode, the bdlc detects a break symbol, it treats the break as a reception error, sets the invalid symbol flag, and exits 4x mode (for example, the rx4xe bit in bcr2 is cleared automatically). if bus control is required after the break symbol is received and the ifs time has elapsed, the programmer must resend the transmission byte using highest priority. 15.7.2.9 idle ? idle bus an idle condition exists on the bus during any passive period after expiration of the ifs period (for example, > 300 s). any node sensing an idle bus condition can begin transmission immediately. 15.7.3 j1850 vpw symbols huntsinger?s variable pulse-width modulation (vpw) is an encoding technique in which each bit is defined by the time bet ween successive transitions and by the level of the bus between transitions (for in stance, active or passive). active and passive bits are used alternately. this encoding technique is used to reduce the number of bus transitions for a given bit rate. each logic 1 or logic 0 contains a single transition and can be at either the active or passive level and one of two lengths, either 64 s or 128 s (t nom at 10.4 kbps baud rate), depending upon the encoding of the previous bit. the start-of-frame (sof), end-of-data (eod), end-of-frame (eof), and inter-frame separation (ifs) symbols are always encoded at an assigned level and length. see figure 15-5 . each message begins with an sof symbol, an active symbol, and, therefore, each data byte (including the crc byte) begins with a passive bit, regardless of whether it is a logic 1 or a logic 0.
byte data link communications (bdlc) data sheet m68hc12b family ? rev. 9.0 238 byte data link communications (bdlc) motorola figure 15-5. j1850 vpw symbols with nominal symbol times all vpw bit lengths stated in the description s here are typical values at a 10.4-kbps bit rate. eof, eod, ifs, and idle, however, are not driven j1850 bus states. they are passive bus periods observed by each node?s cpu. 15.7.3.1 logic 0 a logic 0 is defined as:  an active-to-passive transition followed by a passive period 64 s in length, or  a passive-to-active transition followed by an active period 128 s in length see figure 15-5 (a) . 128 s active passive 64 s or (a) logic 0 128 s active passive 64 s or (b) logic 1 200 s active passive (d) start of frame active passive (f) end of frame 240 s (c) break 200 s (e) end of data 280 s (g) inter-frame 20 s 300 s idle > 300 s (h) idle separation
byte data link communications (bdlc) bdlc mux interface m68hc12b family ? rev. 9.0 data sheet motorola byte data link communications (bdlc) 239 15.7.3.2 logic 1 a logic 1 is defined as:  an active-to-passive transition followed by a passive period 128 s in length, or  a passive-to-active transition followed by an active period 64 s in length see figure 15-5 (b) . 15.7.3.3 normalization bit (nb) the nb symbol has the same property as a lo gic 1 or a logic 0. it is used only in ifr message responses. 15.7.3.4 break signal (break) the break signal is defined as a passive-to- active transition followed by an active period of at least 240 s (see figure 15-5 (c) ). 15.7.3.5 start-of-frame symbol (sof) the sof symbol is defined as passive-to-ac tive transition followed by an active period 200 s in length (see figure 15-5 (d) ). this allows the data bytes which follow the sof symbol to begin with a passi ve bit, regardless of whether it is a logic 1 or a logic 0. 15.7.3.6 end-of-data symbol (eod) the eod symbol is defined as an active-to- passive transition fo llowed by a passive period 200 s in length (see figure 15-5 (e) ). 15.7.3.7 end-of-frame symbol (eof) the eof symbol is defined as an active-to- passive transition followed by a passive period 280 s in length (see figure 15-5 (f) ). if no ifr byte is transmitted after an eod symbol is transmitted, another 80 s the eod becomes an eof, indicating completion of the message. 15.7.3.8 inter-frame separation symbol (ifs) the ifs symbol is defined as a passive period 300 s in length. the 20- s ifs symbol contains no transition, since when it is used it always appends to a 280- s eof symbol (see figure 15-5 (g) ). 15.7.3.9 idle an idle is defined as a passive period greater than 300 s in length.
byte data link communications (bdlc) data sheet m68hc12b family ? rev. 9.0 240 byte data link communications (bdlc) motorola 15.7.4 j1850 vpw valid/invalid bits and symbols the timing tolerances for receiving data bits and symbols fr om the j1850 bus have been defined to allow for variations in osci llator frequencies. in many cases, the maximum time allowed to define a data bit or symbol is equal to the minimum time allowed to define another data bit or symbol. since the minimum resolution of the bdlc for determining what symbol is being received is equal to a single period of the mux interface clock (t bdlc ), an apparent separation in these maximum time/minimum time concurrences equals one cycle of t bdlc . this one clock resolution allows the bdlc to differentiate properly between the different bits and symbols. this is do ne without reducing the valid window for receiving bits and symbols from transmitters onto the j1850 bus, which has varying oscillator frequencies. in huntsinger?s variable pulse width (vpw ) modulation bit encoding, the tolerances for both the passive and active data bits received and the symbols received are defined with no gaps between definitions . for example, the maximum length of a passive logic 0 is equal to the minimu m length of a passive logic 1, and the maximum length of an active logic 0 is equal to the minimum length of a valid sof symbol. see figure 15-6 , figure 15-7 , and figure 15-8 . figure 15-6. j1850 vpw received passive symbol times a bc b a (1) invalid passive bit (2) valid passive logic 0 (3) valid passive logic 1 64 s 128 s cd (4) valid eod symbol 200 s active passive active passive active passive active passive
byte data link communications (bdlc) bdlc mux interface m68hc12b family ? rev. 9.0 data sheet motorola byte data link communications (bdlc) 241 15.7.4.1 inva lid passive bit see figure 15-6 (1) . if the passive-to-active received transition beginning the next data bit or symbol occurs between the active-to-passive tr ansition beginning the current data bit (or symbol) and a , the current bit would be invalid. 15.7.4.2 valid passive logic 0 see figure 15-6 (2) . if the passive-to-active received transition beginning the next data bit (or symbol) occurs between a and b , the current bit would be considered a logic 0. 15.7.4.3 valid passive logic 1 see figure 15-6 (3) . if the passive-to-active received transition beginning the next data bit (or symbol) occurs between b and c , the current bit would be considered a logic 1. 15.7.4.4 valid eod symbol see figure 15-6 (4) . if the passive-to-active received transition beginning the next data bit (or symbol) occurs between c and d , the current symbol would be considered a valid end-of-data symbol (eod). figure 15-7. vpw received passive eof and ifs symbol times cd (2) valid eof+ 280 s 300 s a b ( 1) valid eof symbol active passive active passive ifs symbol
byte data link communications (bdlc) data sheet m68hc12b family ? rev. 9.0 242 byte data link communications (bdlc) motorola 15.7.4.5 valid eo f and ifs symbols in figure 15-7 (1) , if the passive-to-active rece ived transition beginning the sof symbol of the next message occurs between a and b , the current symbol is considered a valid end-of-frame (eof) symbol. see figure 15-7 (2) . if the passive-to-active received transition beginning the sof symbol of the next message occurs between c and d , the current symbol is considered a valid eof symbol followed by a valid inter-frame separation symbol (ifs). all nodes must wait until a va lid ifs symbol time has expired before beginning transmission. however, due to va riations in clock frequencies and bus loading, some nodes may recognize a valid ifs symbol before others and immediately begin transmitting. therefore, any time a node waiting to transmit detects a passive-to-active transition once a valid eof has been detected, it should immediately begin transmission, initiating the arbitration process. 15.7.4.6 idle bus in figure 15-7 (2) , if the passive-to-active received transition beginning the start-of-frame (sof) symbol of t he next message does not occur before d, the bus is considered to be idle, and any node wishing to transmit a message may do so immediately. figure 15-8. j1850 vpw received active symbol times a bc b a (1) invalid active bit (2) valid active logic 1 (3) valid active logic 0 64 s 128 s cd (4) valid sof symbol 200 s active passive active passive active passive active passive
byte data link communications (bdlc) bdlc mux interface m68hc12b family ? rev. 9.0 data sheet motorola byte data link communications (bdlc) 243 15.7.4.7 invalid active bit in figure 15-8 (1) , if the active-to-passive received transition beginning the next data bit (or symbol) occurs between the passive-to-active transition beginning the current data bit (or symbol) and a , the current bit would be invalid. 15.7.4.8 valid active logic 1 in figure 15-8 (2) , if the active-to-passive received transition beginning the next data bit (or symbol) occurs between a and b , the current bit would be considered a logic 1. 15.7.4.9 valid active logic 0 in figure 15-8 (3) , if the active-to-passive received transition beginning the next data bit (or symbol) occurs between b and c , the current bit would be considered a logic 0. 15.7.4.10 valid sof symbol in figure 15-8 (4) , if the active-to-passive received transition beginning the next data bit (or symbol) occurs between c and d , the current symbol would be considered a valid sof symbol. figure 15-9. j1850 vpw received break symbol times 15.7.4.11 valid break symbol in figure 15-9 , if the next active-to-passive received transition does not occur until after e , the current symbol is considered a valid break symbol. a break symbol should be followed by a start-of-frame (sof) symbol beginning the next message to be transmitted onto the j1850 bus. see 15.7.2 j1850 frame format for bdlc response to break symbols. (2) valid break symbol 240 s e active passive
byte data link communications (bdlc) data sheet m68hc12b family ? rev. 9.0 244 byte data link communications (bdlc) motorola 15.7.5 message arbitration message arbitration on the j1850 bus is accomplished in a non-destructive manner, allowing the message with the highes t priority to be transmitted, while any transmitters which lose arbitration simply stop transmitting and wait for an idle bus to begin transmitting again. if the bdlc wants to transmit onto the j1850 bus, but detects that another message is in progress, it waits until the bus is idle. however, if multiple nodes begin to transmit in the same synchroni zation window, message arbitration occurs beginning with the first bit after the so f symbol and continues with each bit thereafter. if a write to the bdr (for in stance, to initiate transmission) occurred on or before 104  t bdlc from the received rising edge, then the bdlc transmits and arbitrates for the bus. if a cpu write to the bdr occurred after 104  t bdlc from the detection of the rising edge, then the bdlc does not transmit, but waits for the next ifs period to expire before attempting to transmit the byte. the variable pulse-width modulation (vpw) symbols and j1850 bus electrical characteristics are chosen care fully so that a logic 0 (active or passive type) always dominates over a logic 1 (active or passive type) simultaneously transmitted. hence, logic 0s are said to be dominant and logic 1s are said to be recessive. when a node detects a dominant bit on bdrxd when it transmitted a recessive bit, it loses arbitration and immediately stops transmitting. this is known as bitwise arbitration (see figure 15-10 ). since a logic 0 dominates a logic 1, the message with the lowest value has the highest priority and always wins arbitration. for instance, a message with priority 000 wins arbitration over a message with priority 011. figure 15-10. j1850 vpw bitwise arbitrations transmitter a transmitter b j1850 bus sof data bit 1 data bit 4 data bit 5 0 transmitter a detects an active state on the bus and stops transmitting transmitter b wins passive active passive active passive active 0 0 1 1 1 data bit 2 1 1 1 data bit 3 0 0 0 0 1 arbitration and continues transmitting
byte data link communications (bdlc) bdlc protocol handler m68hc12b family ? rev. 9.0 data sheet motorola byte data link communications (bdlc) 245 this method of arbitration works no matte r how many bits of priority encoding are contained in the message. during arbitration, or even throughout the transmitting message, when an opposite bit is detected, transmission is stopped im mediately unless it occurs on the eighth bit of a byte. in this case, the bdlc aut omatically appends up to two extra logic 1 bits and then stops transmitting. these tw o extra bits are arbitrated normally and thus do not interfere with another message. the second logic 1 bit is not sent if the first loses arbitration. if the bdlc has lost arbitration to another valid message, then the two extra logic 1s do not corrupt the current message. however, if the bdlc has lost arbitration due to noise on the bus, then the two extra logic 1s ensure that the current message is detected and ignored as a noise-corrupted message. 15.8 bdlc protocol handler the protocol handler is responsible for framing, arbitration, crc generation/checking, and error detection. the protocol handler conforms to sae j1850 ? class b data communications network interface. 15.8.1 protocol architecture the protocol handler contains the state machine, rx shadow register, tx shadow register, rx shift register, tx shift regi ster, and loopback multiplexer as shown in figure 15-11 . figure 15-11. bdlc protocol handler outline rx shift register to cpu interface and rx/tx buffers state machine to physical interface rx data tx data control 8 tx shift register bdtxd rxd control 8 rx shadow register tx shadow register loopback bdrxd bdtxd multiplexer dloop from bcr2 aloop loopback control
byte data link communications (bdlc) data sheet m68hc12b family ? rev. 9.0 246 byte data link communications (bdlc) motorola 15.8.2 rx and tx shift registers the rx shift register gathers received serial data bits from the j1850 bus and makes them available in parallel form to the rx shadow register. the tx shift register takes data, in parallel form, from the tx shadow register and presents it serially to the state machine so that it can be transmitted onto the j1850 bus. 15.8.3 rx and tx shadow registers immediately after the rx shift register has completed shifting in a byte of data, this data is transferred to the rx shadow register and rdrf or rxifr is set (see 15.9.3 bdlc state vector register ). an interrupt is generated if the interrupt enable bit (ie) in bcr1 is set. after the transfer ta kes place, this new data byte in the rx shadow register is available to the cpu inte rface, and the rx shift register is ready to shift in the next byte of data. data in the rx shadow register must be retrieved by the cpu before it is overwritten by new data from the rx shift register. once the tx shift register has completed its shifting operation for the current byte, the data byte in the tx shadow register is loaded into the tx shift register. after this transfer takes place, the tx shadow regist er is ready to accept new data from the cpu when the tdre flag in the bsvr is set. 15.8.4 digital loopback multiplexer the digital loopback multiplexer connec ts rxd to either bdtxd or bdrxd, depending on the state of the dloop bit in the bcr2. (see 15.9.2 bdlc control register 2 .) 15.8.5 state machine all functions associated with performing the protocol are executed or controlled by the state machine. the state machine is responsible for framing, collision detection, arbitration, crc generation /checking, and erro r detection. these sections describe the bdlc?s acti ons in a variety of situations. 15.8.5.1 4x mode the bdlc can exist on the same j1850 bus as modules which use a special 4x (41.6 kbps) mode of j1850 variable pulse width modulation (vpw) operation. the bdlc cannot transmit in 4x mode, but it can receive messages in 4x mode, if the rx4x bit is set in bcr2. if the rx4x bit is not set in the bcr2, any 4x message on the j1850 bus is treated as noise by the bdlc and is ignored. 15.8.5.2 receiving a message in block mode although not a part of the sae j1850 protocol, the bdlc does allow for a special block mode of operation of the receiver. as far as the bdlc is concerned, a block mode message is simply a long j1850 frame that contains an indefinite number of
byte data link communications (bdlc) bdlc protocol handler m68hc12b family ? rev. 9.0 data sheet motorola byte data link communications (bdlc) 247 data bytes. all other features of the frame remain the same, including the sof, crc, and eod symbols. another node wishing to send a block mode transmission must first inform all other nodes on the network that this is about to happen. this is usually accomplished by sending a special predefined message. 15.8.5.3 transmitting a message in block mode a block mode message is transmitted inher ently by simply loading the bytes one by one into the bdr until the message is complete. the programmer should wait until the tdre flag (see 15.9.3 bdlc state vector register ) is set prior to writing a new byte of data into the bdr. the bdlc does not contain any predefined maximum j1850 message length requirement. 15.8.5.4 j1850 bus errors the bdlc detects several types of transmit and receive errors which can occur during the transmission of a message onto the j1850 bus. transmission error ? if the message transmitted by the bdlc contains invalid bits or framing symbols on non-byte boun daries, this constitutes a transmission error. when a transmission error is detec ted, the bdlc immediately ceases transmitting. the error condition is reflected in the bsvr (see table 15-1 ). if the interrupt enable bit (ie in bcr1) is set, a cpu interrupt request from the bdlc is generated. crc error ? a cyclical redundancy check (crc) e rror is detected when the data bytes and crc byte of a received me ssage are processed and the crc calculation result is not equal. the crc code detects any single and 2-bit errors, as well as all 8-bit burst errors and almo st all other types of errors. the crc error flag (in bsvr) is set when a crc error is detected. (see 15.9.3 bdlc state vector register .) symbol error ? a symbol error is detected when an abnormal (invalid) symbol is detected in a message being received from the j1850 bus. the invalid symbol is set when a symbol error is detected. (see 15.9.3 bdlc state vector register .) framing error ? a framing error is detected if an eod or eof symbol is detected on a non-byte boundary from the j1850 bus. a framing error also is detected if the bdlc is transmitting the eod and instead re ceives an active symbol. the symbol invalid, or the out-of-range flag, is set when a framing error is detected. (see 15.9.3 bdlc state vector register .) bus fault ? if a bus fault occurs, the respons e of the bdlc depends upon the type of bus fault.
byte data link communications (bdlc) data sheet m68hc12b family ? rev. 9.0 248 byte data link communications (bdlc) motorola if the bus is shorted to battery, the bdlc waits for the bus to fall to a passive state before it attempts to transmit a message. as long as the short remains, the bdlc never attempts to transmit a message onto the j1850 bus. if the bus is shorted to ground, the bdlc sees an idle bus, begins to transmit the message, and then detects a transmission error (in bsvr), since the short to ground does not allow the bus to be driven to the active (dominant) sof state. the bdlc aborts that transmission and waits for the next cpu command to transmit. in any case, if the bus fault is temporary, as soon as the fault is cleared, the bdlc resumes normal operation. if the bus fault is permanent, it may result in permanent loss of communication on the j1850 bus. (see 15.9.3 bdlc state vector register .) break ? if a break symbol is received while the bdlc is transmitting or receiving, an invalid symbol (in bsvr) in terrupt is generated. reading the bsvr (see 15.9.3 bdlc state vector register ) clears this interrupt condition. the bdlc waits for the bus to idle, then wa its for a start-of-frame (sof) symbol. the bdlc cannot transmit a break symbol. it can receive a break symbol only from the j1850 bus. 15.8.5.5 summary table 15-1 provides a bus error summary. table 15-1. bdlc j1850 bus error summary error condition bdlc function transmission error for invalid bits or framing symbols on non-byte boundaries, invalid symbol interrupt is generated. bdlc stops transmission. cyclical redundancy check (crc) error crc error interrupt is generated. bdlc waits for eof. invalid symbol: bdlc transmits, but receives invalid bits (noise) the bdlc aborts transmission immediately. invalid symbol interrupt is generated. framing error invalid symbol interrupt is gener ated. bdlc waits for end of frame (eof). bus short to v dd the bdlc does not transmit until the bus is idle. invalid symbol interrupt is generated. eof interrupt also must be seen before another transmission attempt. depending on length of the short, loa flag also may be set. bus short to gnd thermal overload shuts down physical interface. fault condition is seen as invalid symbol flag. eof interrupt must also be seen before another transmission attempt. bdlc receives break symbol invalid symbol interrupt is generated. bdlc waits for the next valid sof.
byte data link communications (bdlc) bdlc registers m68hc12b family ? rev. 9.0 data sheet motorola byte data link communications (bdlc) 249 15.9 bdlc registers eight registers are available for cont rolling operation of the bdlc and for communicating data and status information. a full description of each register is given here. 15.9.1 bdlc control register 1 imsg ? ignore message bit this bit disables the receiver until a new start-of-frame (sof) is detected. the bit is cleared automatically by the re ception of an sof symbol or a break symbol. it then generates interrupt requests and allows changes of the status register to occur. however, these interrupts may still be masked by the interrupt enable (ie) bit. when set, all bdlc interrupt requests are masked (except $20 in bsvr) and the status bits are held in their reset state. if this bit is set while the bdlc is receiving a message, the re st of the incoming message is ignored. 1 = disable receiver 0 = enable receiver clks ? clock select bit for j1850 bus communications to take place, the nominal bdlc operating frequency (f bdlc ) must always be 1.048576 mhz or 1 mhz. the clks register bit allows the user to select the frequency (1.048576 mhz or 1 mhz) used to automatically adjust symbol timing. 1 = binary frequency, 1.048576 mhz 0 = integer frequency, 1 mhz r1 and r0 ? rate select bits these bits determine the amount by which the frequency of the mcu cgmxclk signal is divided to form the mux interface clock (f bdlc ) which defines the basic timing resolution of the mux interface. they may be written only once after reset, after which they become read-only bits. the nominal frequency of f bdlc must always be 1.048576 mhz or 1.0 mhz for j1850 bus communications to take place. hence, the value programmed into these bits is dependent on the chosen mcu system clock frequency per table 15-2 . address: $00f8 bit 7654321bit 0 read: imsg clks r1 r0 00 ie wcm write: r r reset:11100000 r = reserved figure 15-12. bdlc control register 1 (bcr1)
byte data link communications (bdlc) data sheet m68hc12b family ? rev. 9.0 250 byte data link communications (bdlc) motorola ie ? interrupt enable bit this bit determines whether the bdlc generates cpu interrupt requests in run mode. it does not clear bsvr interrupts when exiting the bdlc stop or bdlc wait modes. interrupt requests are maintained until all of the interrupt request sources are cleared by performing th e specified actions upon the bdlc?s registers (or an mcu reset sets bsvr bits to $00). interrupts that were pending at the time that this bit is cleared may be lost. if the programmer does not want to use the interrupt capability of the bdlc, the bdlc state vector register (bsvr) c an be polled periodica lly to determine bdlc states. 1 = enable interrupt requests from bdlc 0 = disable interrupt requests from bdlc wcm ? wait clock mode bit this bit determines the operation of the bdlc during cpu wait mode. 0 = run bdlc internal clocks during cpu wait mode. 1 = stop bdlc internal cl ocks during cpu wait mode. 15.9.2 bdlc control register 2 this register controls transmitter operations of the bdlc. aloop ? analog loopback mode bit this bit determines if the j1850 bus is driven by the analog physical interface?s final drive stage. the programmer places the transceiver into loopback mode table 15-2. bdlc rate selection f xclk frequency r1 r0 division f bdlc 1.049 mhz 0 0 1 1.049 mhz 2.097 mhz 0 1 2 1.049 mhz 4.194 mhz 1 0 4 1.049 mhz 8.389 mhz 1 1 8 1.049 mhz 1.000 mhz 0 0 1 1.00 mhz 2.000 mhz 0 1 2 1.00 mhz 4.000 mhz 1 0 4 1.00 mhz 8.000 mhz 1 1 8 1.00 mhz address: $00fa bit 7654321bit 0 read: aloop dloop rx4xe nbfs teod tsifr tmifr1 tmifr0 write: reset:11000000 figure 15-13. bdlc control register 2 (bcr2)
byte data link communications (bdlc) bdlc registers m68hc12b family ? rev. 9.0 data sheet motorola byte data link communications (bdlc) 251 first, then sets aloop which resets the bdlc state machine to a known state. when the user clears aloop, to indicate the transceiver has been taken out of loopback mode, the bdlc waits for an eof symbol before attempting to transmit. most transceivers have the aloop feature available. 1 = input to the analog physical interface?s final drive stage is looped back to the bdlc receiver. the j1850 bus is not driven. 0 = bdlc digital circuitry drives an out put for the j1850 bus. after the bit is cleared, the bdlc requires the bus to be idle for a minimum of end-of-frame symbol time (t trv4 ) before message reception or a minimum of inter-frame symbol time (t trv6 ) before message transmission. dloop ? digital loopback mode bit this bit determines the source to which the bdlc internal digital receive input is connected and can be used to isolate bus fault condition s. if a fault condition has been detected on the bus, this control bit allows the programmer to connect the digital transmit output to the digital re ceive input. in this configuration, data sent from the transmit buffer is reflect ed back into the receive buffer. if no faults exist in the bdlc, the fault is in the phy sical interface block or elsewhere on the j1850 bus. when the dloop bit is set, t he bdlc is disengaged from the j1850 bus. therefore, the bdlc does not receive an edge from the j1850 bus which would normally cause a bsvr non- maskable wakeup interrupt. 1 = bdrxd is connected to bdtxd. th e bdlc is in digital loopback mode. 0 = bdtxd is not connected to bdrxd. the bdlc is taken out of digital loopback mode and can now drive or receive the j1850 bus normally (given aloop is not set). after clearing dloop, the bdlc requires the bus to be idle for a minimum of end-of-frame symbol (t tv4 ) time before allowing reception of a message. the bdlc requires the bus to be idle for a minimum of inter-frame separator symbol (t tv6 ) time before allowing a message to be transmitted. note: the dloop bit is a fault condition aid and should never be altered after the bdr is loaded for transmission. changing dl oop during a transmission may cause corrupted data to be transmitted onto the j1850 network. before going into digital loopback mode, the rxpol bit in the bard register must be set so that the receive polarity is not expected to be inverted. rx4xe ? receive 4x enable bit this bit determines if the bdlc operates at normal transmit and receive speed (10.4 kbps) or receive only at 41.6 kbps. this feature is useful for fast downloading data into a j1850 node for diagnostic or factory programming. 1 = bdlc is put in 4x receive-only operation. 0 = bdlc transmits and receives at 10.4 kbps. reception of a break symbol automatically clears this bit and sets bdlc state vector register (bsvr) to $001c.
byte data link communications (bdlc) data sheet m68hc12b family ? rev. 9.0 252 byte data link communications (bdlc) motorola nbfs ? normalization bit format select bit this bit controls the format of the normalization bit (nb). (see figure 15-14 .) sae j1850 encourages using an active l ong (logic 0) for in-frame responses containing cyclical redundancy check (crc ) and an active short (logic 1) for in-frame responses without crc. 0 = nb that is received or transmitted is a 1 when the response part of an in-frame response (ifr) ends with a crc byte. nb that is received or transmitted is a 0 when the response part of an in-frame response (ifr) does not end with a crc byte. 1 = nb that is received or transmitted is a 0 when the response part of an in-frame response (ifr) ends with a crc byte. nb that is received or transmitted is a 1 when the response part of an in-frame response (ifr) does not end with a crc byte. teod ? transmit end of data bit this bit is set by the programmer to in dicate the end of a message is being sent by the bdlc. it appends an 8-bit crc after completing transmission of the current byte. this bit also is used to end an in-frame response (ifr). if the transmit shadow register is full when teod is set, th e crc byte is transmitted after the current byte in the tx shift register and the byte in the tx shadow register have been transmitted. (see 15.8.3 rx and tx shadow registers for a description of the transmit shadow regi ster.) once teod is set, the transmit data register empty flag (tdre) in the bdlc state vector register (bsvr) is cleared to allow lower priority interrupts to occur. (see 15.9.3 bdlc state vector register .) 1 = transmit end-of-data (eod) symbol 0 = teod bit is cleared automatically at the risi ng edge of the first crc bit that is sent or if an error is detected. when teod is used to end an ifr transmission, teod is cleared wh en the bdlc receives back a valid eod symbol or an error condition occurs. tsifr, tmifr1, tmifr0 ? transmit in-frame response bits these bits control the type of in-frame response being sent. only one of these bits should be set at a time. if more than one are set, the priority encoding logic forces the bits to a known value as shown in table 15-3 . for example, if 011 is written to tsifr, tmifr1, and tmifr0, then internally they are encoded as 010. however, when these bits are read back, they read 011. table 15-3. transmit in-frame response bit encoding write/read (1) 1. shaded cells indicate bits which do not af fect internal interpretation. these bits read back as written. internal interpretation tsifr tmifr1 tmifr0 tsifr tmifr1 tmifr0 00 000 0 1 10 0 01 01 0 00 100 1
byte data link communications (bdlc) bdlc registers m68hc12b family ? rev. 9.0 data sheet motorola byte data link communications (bdlc) 253 figure 15-14. types of in-frame response the bdlc supports the in-frame response (ifr) features of j1850. the four types of j1850 ifr are shown in figure 15-14 . the purpose of the in-frame response modes is to allow multiple nodes to acknowledge receipt of the data by respondi ng with their personal id or physical address in a concatenated manner after they have seen the eod symbol. if transmission arbitration is lost by a n ode while sending its response, it continues to transmit its id/address until observing its unique byte in the response stream. for vpw modulation, the first bit of t he ifr is always passive; therefore, an active normalization bit must be generated by the responder and sent prior to its id/address byte. when there are multiple responders on the j1850 bus, only one normalization bit is sent which assist s all other transmitting nodes to sync their responses. tsifr ? transmit single byte ifr wi th no crc bit (type 1 and type 2) the tsifr bit is used to request the bdlc to transmit the byte in the bdlc data register (bdr) as a single byte ifr with no crc. typically, the byte transmitted is a unique identifier or address of the transmitting (responding) node. see figure 15-14 . 1 = if this bit is set prior to a va lid eod being received with no crc error, once the eod symbol has been receiv ed the bdlc attempts to transmit the appropriate normalization bit followed by the byte in the bdr. 0 = tsifr bit is cleared automatical ly, once the bdlc has successfully transmitted the byte in the bdr onto the bus, or teod is set, or an error is detected on the bus. if the programmer attempts to set th e tsifr bit immediately after the eod symbol has been received from the bus, the tsifr bit remains in the reset state and no attempt is made to transmit the ifr byte. nb data field header crc data field data field data field header header header sof crc crc crc ifr data field eod crc sof sof sof eof eod eod eod eod eof nb id1 idn eod eof nb id type 0 ? no ifr type 1 ? single byte from a single responder type 2 ? single byte from multiple responders type 3 ? multiple bytes from a single responder eod eof
byte data link communications (bdlc) data sheet m68hc12b family ? rev. 9.0 254 byte data link communications (bdlc) motorola if a loss of arbitration occurs when the bdlc attempts to transmit and after the ifr byte winning arbitration completes transmission, the bdlc again attempts to transmit the bdr (with no normalization bit). the bdlc continues transmission attempts until an error is detected on the bus, or teod is set, or the bdlc transmission is successful. if loss of arbitration occurs in the last bit of the ifr byte, two additional 1 bits are not sent out because the bdlc attempts to retransmit the byte in the transmit shift register after the irf byte winn ing arbitration completes transmission. tmifr0 ? transmit multiple byte ifr without crc (type 3) the tmifr0 bit is used to request the bd lc to transmit the byte in the bdlc data register (bdr) as the first byte of a multiple byte ifr without crc. response ifr bytes are still subject to j1850 message length maximums (see 15.7.2 j1850 frame format and figure 15-14 ). 1 = if set prior to a valid eod being received with no crc error, once the eod symbol has been received, the bdlc attempts to transmit the appropriate normalization bit followed by ifr bytes. the programmer should set teod after the last ifr byte has been written into the bdr. after teod has been set, the last ifr byte to be transmitted is the last byte which was written into the bdr. 0 = bit is cleared automatically once t he bdlc has succes sfully transmitted the eod symbol, by the detection of an error on the multiplex bus or by a transmitter underrun caused when the programmer does not write another byte to the bdr after the tdre interrupt. if the tmifr0 bit is set, the bdlc attempts to transmit the normalization symbol followed by the byte in the bdr. after the byte in the bdr has been loaded into the transmit shift register, a tdre interrupt (see 15.9.3 bdlc state vector register ) occurs similar to the main message transmit sequence. the programmer should then load the next byte of the ifr into the bdr for transmission. when the last byte of the ifr has been loaded into the bdr, the programmer should set the teod bit in the bcr2. this instructs the bdlc to transmit an eod symbol once the byte in the bdr is transmitted, indicating the end of the ifr portion of the message frame. the bdlc does not append a crc when the tmifr0 is set. if the programmer attempts to set the tmifr0 bit after the eod symbol has been received from the bus, the tmifr0 bit remains in the reset state, and no attempt is made to transmit an ifr byte. if a loss of arbitration occurs when the bdlc is transmitting, the tmifr0 bit is cleared, and no attempt is made to retransmit the byte in the bdr. if loss of arbitration occurs in the last bit of the ifr byte, two additional 1 bits are sent out. note: the extra logic 1 bits are an enhancement to the j1850 protocol which forces a byte boundary condition fault. this is helpf ul in preventing noise onto the j1850 bus from a corrupted message.
byte data link communications (bdlc) bdlc registers m68hc12b family ? rev. 9.0 data sheet motorola byte data link communications (bdlc) 255 tmifr1 ? transmit multiple byte ifr with crc bit (type 3) the tmifr1 bit requests the bdlc to transmit the byte in the bdlc data register (bdr) as the first byte of a mu ltiple byte ifr with crc or as a single byte ifr with crc. response ifr byte s are still subject to j1850 message length maximums (see 15.7.2 j1850 frame format and figure 15-14 ). 1 = if this bit is set prior to a va lid eod being received with no crc error, once the eod symbol has been received, the bdlc attempts to transmit the appropriate normalization bit followed by ifr bytes. the programmer should set teod after the last ifr byte has been written into the bdr. after teod has been set and the last ifr byte has been transmitted, the crc byte is transmitted. 0 = the bit is cleared automatically, once the bdlc has successfully transmitted the crc byte and eod sy mbol, by the detection of an error on the multiplex bus or by a transmitter underrun caused when the programmer does not write another byte to the bdr after the tdre interrupt. if the tmifr1 bit is set, the bdlc attempts to transmit the normalization symbol followed by the byte in the bdr. after the byte in the bdr has been loaded into the transmit shift register, a tdre interrupt (see 15.9.3 bdlc state vector register ) occurs similar to the main message transmit sequence. the programmer should then load the next byte of the ifr into the bdr for transmission. when the last byte of the ifr has been loaded into the bdr, the programmer should set the teod bit in the bdlc control register 2 (bcr2). this instructs the bdlc to transmit a crc byte once the byte in the bdr is transmitted, and then transmit an eod symbol, indicating the end of the ifr portion of the message frame. however, to transmit a single byte followed by a crc byte, the programmer should load the byte into the bdr before the eod symbol has been received, and then set the tmifr1 bit. once the tdre interrupt occurs, the programmer sets the teod bit in the bcr2. this results in the byte in the bdr being the only byte transmitted before the ifr crc byte, and no tdre interrupt is generated. if the programmer attempts to set the tmifr1 bit immediately after the eod symbol has been received from the bus, the tmifr1 bit remains in the reset state, and no attempt is made to transmit an ifr byte. if a loss of arbitration occurs when the bdlc is transmitting any byte of a multiple byte ifr, the bdlc goes to the loss of arbitration state, sets the appropriate flag, and ceases transmission. if the bdlc loses arbitration during the ifr, the tmifr1 bit is cleared and no attempt is made to retransmit the byte in the bdr. if loss of arbitration occurs in the last bit of the ifr byte, two additional 1 bits are sent out. note: the extra logic 1 bits are an enhancement to the j1850 protocol which forces a byte boundary condition fault. this is helpful in preventing noise on the j1850 bus from corrupting a message.
byte data link communications (bdlc) data sheet m68hc12b family ? rev. 9.0 256 byte data link communications (bdlc) motorola 15.9.3 bdlc state vector register this register is provided to substantially decrease the cpu overhead associated with servicing interrupts while under operation of a multiplex protocol. it provides an index offset that is directly related to the bdlc?s current state, which can be used with a user-supplied jump table to rapidly enter an interrupt service routine. this eliminates the need for the user to maintain a duplicate state machine in software. i0, i1, i2, i3 ? interrupt source bits these bits indicate the source of t he pending interrupt request. bits are encoded according to table 15-4 . bits i0, i1, i2, and i3 are cleared by a read of the bsvr register except when the bdlc data register needs servicing (rdrf, rxifr, or tdre conditions). rxifr and rdrf can only be cleared by a read of the bsvr register followed by a read of bdr. tdre can either be cleared by a read of the bsvr register address: $00f9 bit 7654321bit 0 read:0 0 i3i2i1i0 0 0 write: reset:00000000 = unimplemented figure 15-15. bdlc state vector register (bsvr) table 15-4. interrupt sources bsvr i3 i2 i1 i0 interrupt source priority $00 0 0 0 0 no interrupts pending 0 (lowest) $04 0001 received eof 1 $08 0010 received ifr byte (rxifr) 2 $0c 0 0 1 1 bdlc rx data register full (rdrf) 3 $10 0100 bdlc tx data register empty (tdre) 4 $14 0 1 0 1 loss of arbitration 5 $18 0110 cyclical redundancy check (crc) error 6 $1c 0 1 1 1 symbol invalid or out of range 7 $20 1 0 0 0 wakeup 8 (highest)
byte data link communications (bdlc) bdlc registers m68hc12b family ? rev. 9.0 data sheet motorola byte data link communications (bdlc) 257 followed by a write to the bdlc bdr register, or by setting the teod bit in bcr2. clearing an invalid symbol flag requires an eof flag to be received before the bdlc can receive or transmit. if aloop or dloop in bcr2 is set, the bdlc node is disengaged from the j1850 bus. therefore, the bdlc does not receive any data from the j1850 bus which normally generates bsvr flags. upon receiving a bdlc interrupt, the user may read the value within the bsvr, transferring it to the cpu?s index regist er. the value can be used to index a jump table to access a service routine. for example: service ldx bsvr fetch state vector number jmp jmptab,xenter service routine, * (must end in an rti) * jmptab jmp serve0service condition #0 nop jmp serve1service condition #1 nop jmp serve2service condition #2 nop . . . jmp serve8service condition #8 end note: nop instructions are used only to al ign the jmp instructions onto 4-byte boundaries so that the value in the bsvr c an be used intact. each of the service routines must end with an rti instruction to guarantee correct continued operation of the device. the first entry can be omi tted since it does not correspond to an interrupt. the service routines should clear all of the sources that are causing the pending interrupts. clearing a high priority interrupt may still leave a lower priority interrupt pending, in which case bits i0, i1, and i2 of the bsvr reflect the source of the remaining interrupt request. if fewer states are used or if a different software approach is taken, the jump table can be made smaller or omitted altogether.
byte data link communications (bdlc) data sheet m68hc12b family ? rev. 9.0 258 byte data link communications (bdlc) motorola 15.9.4 bdlc data register this register is used to pass the data to be transmitted to the j1850 bus from the cpu to the bdlc. it is also used to pa ss data received from the j1850 bus to the cpu. each data byte (after the first one) should be written only after a tx data register empty (tdre) state is indicated in the bsvr. data read from this register is the last data byte received from the j1850 bus. this received data should only be read after an rx data register full (rdrf) interrupt has occurred. (see 15.9.3 bdlc state vector register .) the bdr is double buffered via a transmi t shadow register and a receive shadow register. after the byte in the transmit shift register has been transmitted, the byte currently stored in the transmit shadow register is loaded into the transmit shift register. once the transmit sh ift register has shifted the first bit out, the tdre flag is set, and the shadow register is ready to accept the next data byte. the receive shadow register works similarly. once a complete byte has been received, the receive shift register stores the newly received byte into the receive shadow register. the rdrf flag is set to indicate that a new byte of data has been received. the programmer has one bdlc byte recept ion time to read the shadow register and clear the rdrf flag before the shadow register is overwritten by the newly received byte. to abort an in-progress transmission, t he programmer should stop loading data into the bdr. this causes a transmitter underrun error and the bdlc automatically disables the transmitter on the next non-byte boundary. this means that the earliest a transmission can be halted is afte r at least one byte plus two extra logic 1 bits have been transmitted. the receiver pi cks this up as an error and relays it in the state vector register as an invalid symbol error. note: the extra logic 1 bits are an enhancement to the j1850 protocol which forces a byte boundary condition fault. this is helpful in preventing noise on the j1850 bus from corrupting a message. address: $00fb bit 7654321bit 0 read: bd7bd6bd5bd4bd3bd2bd1bd0 write: reset: indeterminate after reset figure 15-16. bdlc data register (bdr)
byte data link communications (bdlc) bdlc registers m68hc12b family ? rev. 9.0 data sheet motorola byte data link communications (bdlc) 259 15.9.5 bdlc analog roundtrip delay register read: anytime write: once in normal modes or anytime in special mode bard programs the bdlc to compensate for various delays of external transceivers. ate ? analog transceiver enable bit the ate bit is used to select either the on-board or an off-chip analog transceiver. 0 = select off-chip analog transceiver. 1 = select on-board analog transceiver. note: this device does not contain an on-board transceiver; ate should be cleared for proper operation. rxpol ? receive pin polarity bit this bit selects the polarity of an incoming signal on the receive pin. some external analog transceivers invert the receive signal from the j1850 bus before feeding it back to the digital receive pin. 0 = select inverted polarity, where external transceiver inverts the receive signal. 1 = select normal/true polarity; true non-inverted signal from j1850 bus, for example, the external transceiver does not invert the receive signal. bo3?bo0 ? bard offset bits these bits are used to compensate for the analog transceiver roundtrip delay. table 15-5 shows the expected transceiver del ay with respect to bard offset values. address: $00fc bit 7654321bit 0 read: ate rxpol 00 bo3 bo2 bo1 bo0 write: reset:11000111 = unimplemented figure 15-17. bdlc analog roundtrip delay register (bard)
byte data link communications (bdlc) data sheet m68hc12b family ? rev. 9.0 260 byte data link communications (bdlc) motorola 15.9.6 port dlc control register read: anytime write: anytime the bdlc port dlc functions as a general -purpose i/o port. bdlc functions takes precedence over the general-purpose port when enabled. bdlcen ? bdlc enable bit 1 = configure i/o pins for bdlc function. bdlc is active. 0 = configure bdlc i/o pins as general-purpose i/o. bdlc is off. table 15-5. offset bit values and transceiver delay bo3?bo0 expected delay ( s) 0000 9 0001 10 0010 11 0011 12 0100 13 0101 14 0110 15 0111 16 1000 17 1001 18 1010 19 1011 20 1100 21 1101 22 1110 23 1111 24 address: $00fd bit 7654321bit 0 read:00000 bdlcen pupdlc rdpdlc write: reset:00000000 = unimplemented figure 15-18. port dlc control register (dlcscr)
byte data link communications (bdlc) bdlc registers m68hc12b family ? rev. 9.0 data sheet motorola byte data link communications (bdlc) 261 pupdlc ? bdlc pullup enable bit 1 = connects internal pull ups to portdlc i/o pins 0 = disconnects internal pullups from portdlc i/o pins rdpdlc ? bdlc reduced drive bit 1 = configure portdlc i/o pins for reduced drive strength. 0 = configure portdlc i/o pins for normal drive strength. 15.9.7 port dlc data register read: anytime write: anytime this register holds data to be driven out on port dlc pins or data received from port dlc pins. when configured as an input, a read returns the pin level. when configured as output, a read returns the latched output data. writes do not change pin state when the pins are configured for bdlc output. upon reset, pins are configured fo r general-purpose high impedance inputs. address: $00fe bit 7654321bit 0 read: 0 bit 6bit 5bit 4bit 3bit 2bit 1bit 0 write: reset:0uuuuuuu alternate pin function: dlctx dlcrx = unimplemented u = unaffected figure 15-19. port dlc data register (portdlc)
byte data link communications (bdlc) data sheet m68hc12b family ? rev. 9.0 262 byte data link communications (bdlc) motorola 15.9.8 port dlc data direction register read: anytime write: anytime dddlc6?dddlc0 ? data direction port dlc bits 1 = configure i/o pin for output 0 = configure i/o pin for input only address: $00ff bit 7654321bit 0 read: 0 dddlc6 dddlc5 dddlc4 dddlc3 dddlc2 dddlc1 dddlc0 write: reset:00000000 = unimplemented figure 15-20. port dlc data direction register (ddrdlc)
m68hc12b family ? rev. 9.0 data sheet motorola mscan12 controller 263 data sheet ? m68hc12b family section 16. mscan12 controller 16.1 introduction the mscan12 is the specific implementati on of the motorola scalable controller area network (mscan) concept targeted for the motorola m68hc12 family of microcontrollers (mcu). the module is a communication controller implementing the can 2.0 a/b protocol as defined in the specification from r obert bosch gmbh dated september 1991. the can protocol was primarily, but not only, designed to be used as a vehicle serial data bus, meeting the specific requirements of this field such as:  real-time processing  reliable operation in the electromag netic interference (emi) environment of a vehicle  cost effectiveness  required bandwidth the mscan12 simplifies the application software by utilizing an advanced buffer arrangement resulting in a predictable real-time behavior. 16.2 external pins the mscan12 uses two external pins , one input (rxcan), and one output (txcan). the txcan output pin represents the logic level on the can: 0 is for a dominant state, and 1 is for a recessive state. rxcan is on bit 0 of port can, and txcan is on bit 1. the remaining six pins of port can are controlled by registers in the mscan12 address space. see 16.12.14 mscan12 port can control register and 16.12.16 mscan12 port can data direction register . a typical can system with mscan12 is shown in figure 16-1 . each can station is connected physica lly to the can bus lines through a transceiver chip. the transceiver is capable of driving the large current needed for the can and has current protection against defected can or defected stations.
mscan12 controller data sheet m68hc12b family ? rev. 9.0 264 mscan12 controller motorola figure 16-1. typical can system with mscan12 16.3 message storage mscan12 facilitates a sophisticated message storage system which addresses the requirements of a broad range of network applications. 16.3.1 background modern application layer software is built on two fundamental assumptions: 1. any can node is able to send out a stream of scheduled messages without releasing the bus between two messages. such nodes will arbitrate for the bus right after sending the previous message and will only release the bus in case of lost arbitration. 2. the internal message queue within any can node is organized so that the highest priority message w ill be sent out first if more than one message is ready to be sent. this behavior cannot be achieved with a singl e transmit buffer. that buffer must be reloaded right after the previous mess age has been sent. this loading process lasts a definite amount of time and has to be completed within the inter-frame sequence (ifs) to be able to send an uninterrupted stream of messages. even if can mscan12 can station 1 can station 2 can station n txcan rxcan can system transceiver . . . controller
mscan12 controller message storage m68hc12b family ? rev. 9.0 data sheet motorola mscan12 controller 265 this is feasible for limited can bus speeds , it requires that the central processor unit (cpu) reacts with short latencies to the transmit interrupt. a double buffer scheme would decouple the re loading of the transmit buffers from the actual message being sent and as such reduces the reaction requirements on the cpu. problems may arise if the sending of a message would be finished just while the cpu reloads the second buffer. in that case, no buffer would then be ready for transmission and the bus would be released. at least three transmit buffers are required to meet the first requirement under all circumstances. the mscan12 has three transmit buffers. the second requirement calls for some sort of internal priorization which the mscan12 implements with the ?local priority? concept described here. 16.3.2 receive structures the received messages are stored in a 2-stage first-in/first-out (fifo) input. the two message buffers are mapped in to a single memory area (see figure 16-2 ). while the background receive buffer (rxbg) is exclusively associated to the mscan12, the foreground receive buffer (rxfg) is addressable by the cpu12. this scheme simplifies the handler software since only one address area is applicable for the receive process. both buffers have 13 bytes for storing the can control bits, the identifier (standard or extended), and the data contents. for details, see 16.11 programmer?s model of message storage . the receiver full flag (rxf) in the mscan 12 receiver flag register (crflg) signals the status of the foreground receive buffer. when the buffer contains a correctly received message with matching identifier, this flag is set. see 16.12.5 mscan12 receiver flag register . on reception, each message is checked to see if it passes the filter (for details see 16.4 identifier acceptance filter ) and in parallel is written into rxbg. the mscan12 copies the content of rxbg into rxfg (1) , sets the rxf flag, and emits a receive interrupt to the cpu (2) . the user?s receive handler has to read the received message from rxfg and then re set the rxf flag to acknowledge the interrupt and to release the foreground buffer. a new message, which can follow immediately after the ifs field of the ca n frame, is received into rxbg. the over-writing of the background buffer is independent of the identifier filter function. 1. only if the rxf flag is not set 2. the receive interrupt will occur only if not masked. a polling scheme can be applied on rxf also.
mscan12 controller data sheet m68hc12b family ? rev. 9.0 266 mscan12 controller motorola figure 16-2. user model for message buffer organization when the mscan12 module is transmitting, the mscan12 receives its own messages into the background receive buffe r, rxbg, but does not overwrite rxfg, generate a receive interrupt, or acknowledge its own messages on the can bus. the exception to this rule is in loop-back mode (see 16.12.2 mscan12 module control register 1 ) where the mscan12 treats its own messages exactly like all other incoming messages. the mscan12 re ceives its own transmitted messages in the event that it loses arbitration. if arbitration is lost, the mscan12 must be prepared to become the receiver. an overrun condition occurs when both the foreground and the background receive message buffers are filled with correctly received messages with accepted identifiers and another message is corre ctly received from the bus with an accepted identifier. the latter message is discarded and an error interrupt with overrun indication is generat ed if enabled. the mscan12 is still able to transmit messages with both receive message buffers filled, but all incoming messages are discarded. rxfg rxbg tx0 txe prio txe prio txe prio mscan12 cpu bus rxf tx1 tx2
mscan12 controller message storage m68hc12b family ? rev. 9.0 data sheet motorola mscan12 controller 267 16.3.3 transmit structures the mscan12 has a triple transmit buffer scheme to allow multiple messages to be set up in advance and to achieve an optimized real-time performance. the three buffers are arranged as shown in figure 16-2 . all three buffers have a 13-byte data structure similar to the outline of the receive buffers (see 16.11 programmer?s model of message storage ). an additional transmit buffer priority register (tbpr) cont ains an 8-bit local priority field (prio). see 16.11.5 transmit buffer priority register . to transmit a message, the cpu12 has to identify an available transmit buffer which is indicated by a set transmit buffer empty (txe) flag in the mscan12 transmitter flag register (ctflg). see 16.12.7 mscan12 transmitter flag register . the cpu12 then stores the identifier, the control bits, and the data content into one of the transmit buffers. finally, the buffe r has to be flagged ready for transmission by clearing the txe flag. the mscan12 then will schedule the message for transmission and will signal the successful transmission of the buffer by setting the txe flag. a transmit interrupt will be emitted (1) when txe is set, and this can be used to drive the application software to reload the buffer. if more than one buffer is scheduled for tr ansmission when the can bus becomes available for arbitration, th e mscan12 uses the local priority setting of the three buffers for prioritizing. for this purpose, every transmit buffer has an 8-bit local priority field (prio). the application so ftware sets this field when the message is set up. the local priority reflects the priority of this particular message relative to the set of messages being emitted from this node. the lowest binary value of the prio field is defined to be the highest priority. the internal scheduling process takes plac e whenever the mscan12 arbitrates for the bus. this is also the case after the occurrence of a transmission error. when a high priority message is scheduled by the application software, it may become necessary to abort a lower priority message being set up in one of the three transmit buffers. because messages that are already under transmission cannot be aborted, the user has to request the abort by setting the corresponding abort request flag (abtrq) in the trans mission control register (ctcr). the mscan12 grants the request, if possible, by setting the corresponding abort request acknowledge (abtak) and the txe flag to release the buffer and by generating a transmit interrupt. the transmit interrupt handler software can tell from the setting of the abtak flag whether the message was aborted (abtak = 1) or sent in the meantime (abtak = 0). 1. the transmit interrupt is generated only if no t masked. a polling scheme can be applied on txe also.
mscan12 controller data sheet m68hc12b family ? rev. 9.0 268 mscan12 controller motorola 16.4 identifier acceptance filter the identifier acceptance registers (cidar0?ciadar7) define the acceptable patterns of the standard or extended identifier (id10?id0 or id28?id0). any of these bits can be marked don?t care in the identifier mask registers (cidmr0?cidmr7). a filter hit is indicated to the application software by:  a set rxf (receive buffer full flag) see 16.12.5 mscan12 receiver flag register ) and  three bits in the identifier acceptance control register see 16.12.9 mscan12 identifier acceptance control register ). these identifier hit flags (idhit2?idhit0) clearly identify the filter section that caused the acceptance. they simplify the application software?s task to identify the cause of the receiver interrupt. when more than one hit occurs (two or more filters match), the lower hit has priority. a flexible, programmable generic identifi er acceptance filter has been introduced to reduce the cpu interrupt loading. the filt er is programmable to operate in four different modes: 1. two identifier acceptance filters, each to be applied to the full 29 bits of the identifier and to three bits of the can frame: rtr, ide, and srr. this mode implements two filters for a full length can 2.0b compliant extended identifier. figure 16-3 shows how the first 32-bit filter bank (cidar0?cidar3, cidmr0?cidmr3) produc es a filter 0 hit. similarly, the second filter bank (cidar4?cuidar7, cidmr4?cidmr7) produces a filter 1 hit. figure 16-3. 32-bit maskable identifier acceptance filter cidmr2 id28 id21 id20 id15 id14 id7 id6 rtr id10 id3 id2 ide ac7 idr0 idr0 idr1 idr1 idr2 idr3 ac0 ac7 ac0 ac7 ac7 ac0 ac0 ac7 ac0 ac7 ac0 ac7 ac0 ac7 ac0 cidmro cidmr1 cidmr3 cidar3 cidar2 cidar1 cidaro id accepted (filter 0 hit)
mscan12 controller identifier acceptance filter m68hc12b family ? rev. 9.0 data sheet motorola mscan12 controller 269 2. four identifier acceptance filters, each to be applied to: a. 11 bits of the identifier and the rtr bit of can 2.0a messages, or b. 14 most significant bits of the identifier of can 2.0b messages figure 16-4 shows how the first 32-bit filter bank (cidar0?cidar3, cidmr0?cidmr3) produces filter 0 and 1 hit. similarly, the second filter bank (cidar4?cuidar7, cidmr4?cidmr7) produces filter 2 and three hits. figure 16-4. 16-bit maskable acceptance filters 3. eight identifier acceptance filters, each to be applied to the first eight bits of the identifier. this mode implements eight independent filters for the first eight bits of a can 2.0a compliant standard identifier or of a can 2.0b compliant extended identifier. figure 16-5 shows how the first 32-bit filter bank (cidar0?cidar3, cidmr0?cidmr3) produces filter 0 to three hits. similarly, the second filter bank (cidar4?cuidar7, cidmr4?cidmr7) produces filter 4 to seven hits. 4. closed filter. no can message will be copied into the foreground buffer rxfg, and the rxf flag will never be set. id28 id21 id20 id15 id14 id7 id6 rtr id10 id3 id2 ide ac7 idr0 idr0 idr1 idr1 idr2 idr3 ac0 ac7 ac0 ac7 ac0 ac7 ac0 cidmro cidmr1 cidar1 cidaro id accepted (filter 0 hit) id accepted (filter 1 hit) ac7 ac0 ac7 ac0 ac7 ac0 ac7 ac0 cidmr2 cidmr3 cidar3 cidar2
mscan12 controller data sheet m68hc12b family ? rev. 9.0 270 mscan12 controller motorola figure 16-5. 8-bit maskable acceptance filters id28 id21 id20 id15 id14 id7 id6 rtr id10 id3 id2 ide ac7 idr0 idr0 idr1 idr1 idr2 idr3 ac0 ac7 ac0 cidmro cidaro id accepted (filter 0 hit) ac7 ac0 ac7 ac0 cidmr1 cidar1 ac7 ac0 ac7 ac0 cidmr2 cidar2 id accepted (filter 1 hit) id accepted (filter 2 hit) ac7 ac0 ac7 ac0 cidmr3 cidar3
mscan12 controller interrupts m68hc12b family ? rev. 9.0 data sheet motorola mscan12 controller 271 16.5 interrupts the mscan12 supports four interrupt vectors mapped onto 11 different interrupt sources, any of which can be indi vidually masked. for details, see 16.12.5 mscan12 receiver flag register to 16.12.8 mscan12 transmitter control register . 1. transmit interrupt: at least one of the three transmit buffers is empty (not scheduled) and can be loaded to schedule a message for transmission. the empty message buffers txe flags are set. 2. receive interrupt: a message has been successfully received and loaded into the foreground receive buffer. this interrupt will be emitted immediately after receiving the end of frame (eof) symbol. the rxf flag is set. 3. wakeup interrupt: an activity on the can bus occurred during mscan12 internal sleep mode. 4. error interrupt: an overrun, error, or warning condition occurred. the receiver flag register (crflg) will indicate one of these conditions: ? overrun: an overrun condition as described in 16.3.2 receive structures has occurred. ? receiver warning: the receive error counter has reached the cpu warning limit of 96. ? transmitter warning: the transmit error counter has reached the cpu warning limit of 96. ? receiver error passive: the receive error counter has exceeded the error passive limit of 127 and mscan12 has gone to error passive state. ? transmitter error passive: the transmit error counter has exceeded the error passive limit of 127 and mscan12 has gone to error passive state. ? bus off: the transmit error counter has exceeded 255 and mscan12 has gone to bus-off state. 16.5.1 interrupt acknowledge interrupts are associated directly with one or more status flags in either the mscan12 receiver flag register (crflg ) or the mscan12 transmitter control register (ctcr). interrupts are pending as long as one of the corresponding flags is set. the flags in the aforementioned registers must be reset within the interrupt handler to handshake the interrupt. the flags are reset through writing a 1 to the corresponding bit position. a flag cannot be cleared if the respective condition still prevails. note: bit manipulation instructions (bset) must not be used to clear interrupt flags.
mscan12 controller data sheet m68hc12b family ? rev. 9.0 272 mscan12 controller motorola 16.5.2 interrupt vectors the mscan12 supports four interrupt vectors as shown in table 16-1 . the vector addresses are dependent on the chip integration and to be defined. the relative interrupt priority is also integration dependent and to be defined. 16.6 protocol viol ation protection the mscan12 will protect the user from accidentally violating the can protocol through programming errors. the protecti on logic implements these features:  the receive and transmit error counters cannot be written or otherwise manipulated.  all registers which control the conf iguration of the mscan12 cannot be modified while the mscan12 is online. the sftres bit in cmcr0 (see 16.12.1 mscan12 module control register 0 ) serves as a lock to protect these registers: ? mscan12 module control register 1 (cmcr1) ? mscan12 bus timing register 0 and 1 (cbtr0 and cbtr1) ? mscan12 identifier acceptance control register (cidac) ? mscan12 identifier acceptance registers (cidar0?cidar7) ? mscan12 identifier mask registers (cidmr0?cidmr7)  the txcan pin is forced to recessive if the cpu goes into stop mode. table 16-1. mscan12 interrupt vectors function source local mask global mask wakeup wupif wupie i bit error interrupts rwrnif rwrnie twrnif twrnie rerrif rerrie terrif terrie boffif boffie ovrif ovrie receive rxf rxfie transmit txe0 txeie0 txe1 txeie1 txe2 txeie2
mscan12 controller low-power modes m68hc12b family ? rev. 9.0 data sheet motorola mscan12 controller 273 16.7 low-power modes in addition to normal mode, the mscan12 has three modes with reduced power consumption compared to normal mode. in sleep and soft-reset mode, power consumption is reduced by stopping all clocks except those to access the registers. in power-down mode, all clocks are stopped and no power is consumed. the wait-for-interrupt (wai) and stop instructions put the mcu in low power-consumption standby modes. table 16-2 summarizes the combinations of mscan12 and cpu modes. a particular comb ination of modes is entered for the given settings of the bits cswai, slpak, and sftres. for all modes, an mscan wakeup interrupt can occur only if slpak = wupie = 1. while the cpu is in wait mode, the mscan12 can be operated in normal mode and emit interrupts. (registers can be accessed via background debug mode.) 16.7.1 mscan12 sleep mode the cpu can request the mscan12 to enter this low-power mode by asserting the slprq bit in the module c onfiguration register. see figure 16-6 . the time when the mscan12 enters sl eep mode depends on its activity. for instance,  if it is transmitting, it continues to transmit until there are no more messages to be transmitted and then goes into sleep mode.  if it is receiving, it waits for the end of this message and then goes into sleep mode.  if it is neither transmitting nor receiv ing, it immediately goes into sleep mode. table 16-2. mscan12 versus cpu operating modes mscan mode cpu mode stop wait run power-down cswai = x (1) slpak = x sftres = x 1. x means don?t care. cswai = 1 slpak = x sftres = x sleep cswai = 0 slpak = 1 sftres = 0 cswai = x slpak = 1 sftres = 0 soft reset cswai = 0 slpak = 0 sftres = 1 cswai = x slpak = 0 sftres = 1 normal cswai = 0 slpak = 0 sftres = 0 cswai = x slpak = 0 sftres = 0
mscan12 controller data sheet m68hc12b family ? rev. 9.0 274 mscan12 controller motorola figure 16-6. sleep request/acknowledge cycle note: the application software must avoid setti ng up a transmission (by clearing one or more txe flag(s)) and immediately reque st sleep mode (by setting slprq). it then depends on the exact sequence of operations whether the mscan12 starts transmitting or goes in to sleep mode directly. during sleep mode, the slpak flag is se t. the application software should use slpak as a handshake indicati on for the request (slprq) to go into sleep mode. when in sleep mode, the mscan12 stops its internal clocks. however, clocks to allow register accesses still run. if the mscan12 is in bus-off state, it stops counting the 128 x 11 consecutive recessive bits due to the stopped clocks. the txcan pin stays in recessive state. if rxf = 1, the message can be read and rxf can be cleared. copying rxbg into rxfg doesn?t take place while in sleep mode. it is possible to access the transmit buffers and to clear the txe flags. no message abort takes place while in sleep mode. the mscan12 leaves sleep mode (wak eup) when one of these occurs:  bus activity occurs.  mcu clears the slprq bit.  mcu sets sftres. note: the mcu cannot clear the slprq bit before the mscan12 is in sleep mode (slpak = 1). mscan12 sleeping slprq = 1 slpak = 1 mscan12 running slprq = 0 slpak = 0 sleep request slprq = 1 slpak = 0 mcu ms can12 mcu or mscan12
mscan12 controller low-power modes m68hc12b family ? rev. 9.0 data sheet motorola mscan12 controller 275 after wakeup, the mscan12 waits for 11 cons ecutive recessive bits to synchronize to the bus. as a consequence, if the msca n12 is wakened by a can frame, this frame is not received. the receive message buffers (rxfg and rxbg) contain messages if they were received before sleep mode was entered. all pending actions are executed upon wakeup: copyin g of rxbg into rxfg, message aborts, and message transmissions. if the mscan12 is still in bus-off state after sleep mode was left, it continues counting the 128 x 11 consecutive recessive bits. 16.7.2 mscan12 soft-reset mode in soft-reset mode, the mscan12 is stopped. registers can still be accessed. this mode is used to initialize the module co nfiguration, bit timing, and the can message filter. see 16.12.1 mscan12 module control register 0 for a complete description of the soft-reset mode. when setting the sftres bit, the mscan12 immediately stops all ongoing transmissions and receptions, potentially causing the can pr otocol violations. note: the user is responsible for ensuring that the mscan12 is not active when soft-reset mode is entered. the recommended procedure is to put the mscan12 into sleep mode before the sftres bit is set. 16.7.3 mscan12 power-down mode the mscan12 is in power-down mode when either of these occurs:  cpu is in stop mode.  cpu is in wait mode and the cswai bit is set. see 16.12.1 mscan12 module control register 0 and 16.12.2 mscan12 module control register 1 . when entering power-down mode, the mscan12 immediately stops all on-going transmissions and receptions, potentia lly causing can protocol violations. note: the user should be careful that the mscan12 is not active when power-down mode is entered. the recommended procedure is to put the mscan12 into sleep mode before the stop instruction ? or the wai instruction, if cswai is set ? is executed. to protect the can bus system from fatal co nsequences of violations to this rule, the mscan12 will drive the txca n pin into recessive state. in power-down mode, no registers can be accessed. 16.7.4 programmable wakeup function the mscan12 can be programmed to apply a low-pass filter function to the rxcan input line while in sleep mode. see control bit wupm in the module control register, 16.12.2 mscan12 module control register 1 . this feature can be used to protect the mscan12 from wakeup due to short glitches on the can bus lines. such glitches can result from electromagnetic interference within noisy environments.
mscan12 controller data sheet m68hc12b family ? rev. 9.0 276 mscan12 controller motorola 16.8 timer link the mscan12 generates a timer signal w henever a valid frame has been received. because the can specification defines a frame to be valid if no errors occurred before the eof field has been transmi tted successfully, the timer signal is generated right after the eof. a pulse of one bit time is generated. as the mscan12 receiver engine also receives t he frames being sent by itself, a timer signal also is generated after a successful transmission. the previously described timer signal can be routed into the on-chip timer interface module (tim). this signal is connected to the timer n channel m input (1) under the control of the timer link enable (tlnken) bit in the cmcr0. after timer n has been programmed to capt ure rising edge events, it can be used under software control to generate 16 bit-ti me stamps which can be stored with the received message. 16.9 clock system figure 16-7 shows the structure of the mscan12 clock generation circuitry. with this flexible clocking scheme the ms can12 is able to handle can bus rates ranging from 10 kbps to 1 mbps. figure 16-7. clocking scheme the clock source bit (clksrc) in the mscan12 module control register (cmcr1) (see 16.12.3 mscan12 bus timing register 0 ) defines whether the mscan12 is connected to the output of the crystal os cillator (extali) or to a clock twice as fast as the system clock (eclk). the clock source has to be chosen so that the tight oscillator tolerance requirements (up to 0.4 percent) of the ca n protocol are met. additionally, for high can bus rates (1 mbps), a 50 percent duty cycle of the clock is required. 1. the timer channel being used for the timer link is integration dependent. mscan12 cgm sysclk extali cgmcanclk prescaler (1...64) time quanta clock clksrc clksrc
mscan12 controller clock system m68hc12b family ? rev. 9.0 data sheet motorola mscan12 controller 277 for microcontrollers without the cgm module, cgmcanclk is driven from the crystal oscillator (extali). a programmable prescaler is used to generate out of mscanclk the time quanta (tq) clock. a time quantum is the atomic unit of time handled by the mscan12. a bit time is subdivided into three segments (1) :  sync_seg ? this segment has a fixed length of one time quantum. signal edges are expected to happen within this section.  time segment 1 ? this segment includes the prop_seg and the phase_seg1 of the can standard. it can be programmed by setting the parameter tseg1 to consist of 4 to 16 time quanta.  time segment 2 ? this segment represents the phase_seg2 of the can standard. it can be programmed by setting the tseg2 parameter to be 2 to 8 time quanta. the synchronization jump width can be programmed in a range of 1 to 4 time quanta by setting the sjw parameter. these parameters can be set by programming the bus timing registers (cbtr0 and cbtr1). see 16.12.3 mscan12 bus timing register 0 and 16.12.4 mscan12 bus timing register 1 . note: it is the user?s responsibility to make sure that the bit time settings are in compliance with the can standard. table 16-3 gives an overview on the can-conforming segment settings and the related parameter values. 1. for further explanation of the underlying co ncepts, refer to iso/di s 11519-1, section 10.3. f tq f cgmcanclk presc value t --------------------------------------- = bitrate f tq number of timequanta tt ----------------------------------------------------------------------------- =
mscan12 controller data sheet m68hc12b family ? rev. 9.0 278 mscan12 controller motorola figure 16-8. segments within the bit time table 16-3. can standard compliant bit time segment settings time segment 1 tseg1 time segment 2 tseg2 synchronize jump width sjw 5.. 10 4 .. 9 2 1 1 .. 2 0 .. 1 4 .. 11 3 .. 10 3 2 1 .. 3 0 .. 2 5 .. 12 4 .. 11 4 3 1 .. 4 0 .. 3 6 .. 13 5 .. 12 5 4 1 .. 4 0 .. 3 7 .. 14 6 .. 13 6 5 1 .. 4 0 .. 3 8 .. 15 7 .. 14 7 6 1 .. 4 0 .. 3 9 .. 16 8 .. 15 8 7 1 .. 4 0 .. 3 sync _seg time segment 1 time seg. 2 1 4 ... 16 2 ... 8 8... 25 time quanta = 1 bit time nrz signal sample point (single or triple sampling) prop_seg + phase_seg1 (phase_seg2 transmit point
mscan12 controller memory map m68hc12b family ? rev. 9.0 data sheet motorola mscan12 controller 279 16.10 memory map the mscan12 occupies 128 bytes in the cpu12 memory space. the background receive buffer can be read only in test mode. 16.11 programmer?s mo del of message storage this subsection details th e organization of the receive and transmit message buffers and the associated control registers. 16.11.1 message buffer organization figure 16-10 shows the organization of a single message buffer. for reasons of programmer interface simplification, the receive and transmit message buffers have the same register organization. each message buffer allocates 16 bytes in the memory map containing:  13-byte data structure which includes an identifier section (idrn), a data section (dsrn), and the data length register (dlr)  transmit buffer priority register (tbpr) which is only applicable for transmit buffers. see 16.11.5 transmit buffer priority register  two unused bytes $0100 control registers 9 bytes $0108 $0109 reserved 5 bytes $010d $010e error counters 2 bytes $010f $0110 identifier filter 16 bytes $011f $0120 reserved 29 bytes $013c $013d port can registers 3 bytes $013f $0140 receive buffer (rxfg) $014f $0150 transmit buffer 0 (tx0) $015f $0160 transmit buffer 1 (tx1) $016f $0170 transmit buffer 2 (tx2) $017f figure 16-9. mscan12 memory map
mscan12 controller data sheet m68hc12b family ? rev. 9.0 280 mscan12 controller motorola all bits of the 13-byte data structure are undefined out of reset. note: the receive buffer can be read anytime but cannot be written. the transmit buffers can be read or written anytime. 16.11.2 identifier registers the bosch can 2.0a and 2.0b protocol specifications allow for two different sizes of message identifiers. the bosch can 2.0a specification requires an 11-bit identifier in the message buffer and the bosch can 2.0b specification requires a 29-bit identifier in the message buffer. the resulting message buffers are referred to as standard and extended formats, respectively. the identifier registers (idrn) in the memory map can be configured to create either the 11-bit (idr10?idr0) identifier necessary for the standard format or the 29-bit (idr28?idr0) identifier necessary for the extended format. figure 16-11 details the identifier structure used in the standard format while figure 16-12 details the identifier structure used in the extended format. id10/id28 is the most significant bit and is transmitted first on th e bus during the arbitration procedure. the priority of an identifier is defined to be the highest for the smallest binary number. address ( 1) register name 01x0 identifier register 0 01x1 identifier register 1 01x2 identifier register 2 01x3 identifier register 3 01x4 data segment register 0 01x5 data segment register 1 01x6 data segment register 2 01x7 data segment register 3 01x8 data segment register 4 01x9 data segment register 5 01xa data segment register 6 01xb data segment register 7 01xc data length register 01xd transmit buffer priority register (2) 01xe unused 01xf unused 1. x is 4, 5, 6, or 7 depending on which buffer, rxfg, tx0, tx1, or tx2, respectively. 2. not applicable for receive buffers. figure 16-10. message buffer organization
mscan12 controller programmer?s model of message storage m68hc12b family ? rev. 9.0 data sheet motorola mscan12 controller 281 srr ? substitute remote request bit this fixed recessive bit is used only in extended format. it must be set to 1 by the user for transmission buffers and will be stored as received on the can bus for receive buffers. ide ? id extended flag this flag indicates whether the extended or standard identifier format is applied in this buffer. in case of a receive buffer, the flag is set as received and indicates to the cpu how to process the buffer identifier registers. in case of a transmit buffer the flag indicates to the msca n12 what type of identifier to send. 0 = standard format (11 bit) 1 = extended format (29 bit) addr. (1) register name bit 7 6 5 4 3 2 1 bit 0 $01x0 identifier register 0 (idr0) read: id10 id9 id8 id7 id6 id5 id4 id3 write: reset: undefined out of reset $01x1 identifier register 1 (idr1) read: id2 id1 id0 rtr ide write: reset: undefined out of reset $01x2 identifier register 2 (idr2) read: write: reset: undefined out of reset $01x3 identifier register 3 (idr3) read: write: reset: undefined out of reset note 1. x is 4, 5, 6, or 7 depending on which buffer, rxfg, tx0, tx1, or tx3, respectively. = unimplemented figure 16-11. identifier mapping in the standard format addr. (1) register name bit 7 6 5 4 3 2 1 bit 0 $01x0 identifier register 0 (idr0) read: id28 id27 id26 id25 id24 id23 id22 id21 write: reset: undefined out of reset $01x1 identifier register 1 (idr1) read: id20 id19 id18 srr ide id17 id16 id15 write: reset: undefined out of reset $01x2 identifier register 2 (idr2) read: id14 id13 id12 id11 id10 id9 id8 id7 write: reset: undefined out of reset $01x3 identifier register 3 (idr3) read: id6 id5 id4 id3 id2 id1 id0 rtr write: reset: undefined out of reset note 1. x is 4, 5, 6, or 7 depending on which buffer, rxfg, tx0, tx1, or tx3, respectively. figure 16-12. identifier mapping in the extended format
mscan12 controller data sheet m68hc12b family ? rev. 9.0 282 mscan12 controller motorola rtr ? remote transmission request flag this flag reflects the status of the remote transmission request bit in the can frame. in case of a receive buffer, it indicates the status of the received frame and supports the transmission of an answering frame in software. in case of a transmit buffer, this flag defines the setting of the rtr bit to be sent. 0 = data frame 1 = remote frame 16.11.3 data length register the data length register (dlr) keeps t he data length field of the can frame. dlc3?dlc0 ? data length code bits the data length code contains the number of bytes (data byte count) of the respective message. at transmission of a remote frame, the data length code is transmitted as programmed while the numbe r of transmitted bytes is always 0. the data byte count ranges from 0 to 8 for a data frame. table 16-4 shows the effect of setting the dlc bits. address: $01xc bit 7654321bit 0 read: dlc3 dlc2 dlc1 dlc0 write: reset: undefined out of reset = unimplemented note: x is 4, 5, 6, or 7 depending on which buffer, rxfg, tx0, tx1, or tx3, respectively. figure 16-13. data length register (dlr) table 16-4. data length codes data length code data byte count dlc3 dlc2 dlc1 dlc0 00000 00011 00102 00113 01004 01015 01106 01117 10008
mscan12 controller programmer?s model of message storage m68hc12b family ? rev. 9.0 data sheet motorola mscan12 controller 283 16.11.4 data segment registers the eight data segment registers (dsr0?dsr7) contain the data to be transmitted or being received. the number of bytes to be transmitted or received is determined by the data length code in the corresponding dlr. data is transmitted starting from the data segment register 0 (dsr0), beginning with the most significant bit (db7), and continuing until the number of bytes specified in the data length register (dlr) is complete. addr. (1) register name bit 7 6 5 4 3 2 1 bit 0 $01x4 data segment register 0 (dsr0) read: db7 db6 db5 db4 db3 db2 db1 db0 write: reset: undefined out of reset $01x5 data segment register 1 (dsr1) read: db7 db6 db5 db4 db3 db2 db1 db0 write: reset: undefined out of reset $01x6 data segment register 2 (dsr2) read: db7 db6 db5 db4 db3 db2 db1 db0 write: reset: undefined out of reset $01x7 data segment register 3 (dsr3) read: db7 db6 db5 db4 db3 db2 db1 db0 write: reset: undefined out of reset $01x8 data segment register 4 (dsr4) read: db7 db6 db5 db4 db3 db2 db1 db0 write: reset: undefined out of reset $01x9 data segment register 5 (dsr5) read: db7 db6 db5 db4 db3 db2 db1 db0 write: reset: undefined out of reset $01xa data segment register 6 (dsr6) read: db7 db6 db5 db4 db3 db2 db1 db0 write: reset: undefined out of reset $01xb data segment register 7 (dsr7) read: db7 db6 db5 db4 db3 db2 db1 db0 write: reset: undefined out of reset note 1.: x is 4, 5, 6, or 7 depending on which buffer, rxfg, tx0, tx1, or tx3, respectively. figure 16-14. data segment registers (dsrn)
mscan12 controller data sheet m68hc12b family ? rev. 9.0 284 mscan12 controller motorola 16.11.5 transmit buffer priority register prio7?prio0? local priority this field defines the local priority of the associated message buffer. the local priority is used for the internal priori tization process of the mscan12 and is defined to be highest for the smallest binary number. the mscan12 implements this internal prioritization mechanism: ? all transmission buffers with a cl eared txe flag participate in the prioritization right before the start of frame (sof) is sent. ? the transmission buffer with the lowe st local priority field wins the prioritization. ? in case of more than one buffer ha ving the same lowest priority, the message buffer with the lowest index number wins. 16.12 programmer?s model of control registers the programmer?s model has been laid out for maximum simplicity and efficiency. 16.12.1 mscan12 module control register 0 cswai ? can stops in wait mode bit 0 = the module is not affected during wait mode. 1 = the module ceases to be clocked during wait mode. synch ? synchronized status bit this bit indicates whether the mscan12 is synchronized to the can bus and as such can participate in the communication process. 0 = mscan12 is not synchronized to the can bus. 1 = mscan12 is synchronized to the can bus. address: $01xd bit 7654321bit 0 read: prio7 prio6 prio5 prio4 prio3 prio2 prio1 prio0 write: reset: unaffected by reset note 1. x is 5, 6, or 7 depending on which buffer tx0, tx1, or tx2, respectively. figure 16-15. transmit buffer priority register (tbpr) address: $0100 bit 7654321bit 0 read: 0 0 cswai synch tlnken slpak slprq sftres write: reset:00100001 = unimplemented figure 16-16. mscan12 module control register 0 (cmcr0)
mscan12 controller programmer?s model of control registers m68hc12b family ? rev. 9.0 data sheet motorola mscan12 controller 285 tlnken ? timer enable flag this flag is used to establish a link between the mscan12 and the on-chip timer. see 16.8 timer link . 0 = port is connecte d to the timer input. 1 = mscan12 timer signal output is connected to the timer input. slpak ? sleep mode acknowledge flag this flag indicates whether the mscan12 is in module inter nal sleep mode. it shall be used as a handshake for the sleep mode request. see 16.7.1 mscan12 sleep mode . 0 = wakeup ? the mscan12 is not in sleep mode. 1 = sleep ? the mscan12 is in sleep mode. slprq ? sleep request, go to sleep mode flag this flag requests the mscan12 to go into an internal power-saving mode (see 16.7.1 mscan12 sleep mode ). 0 = wakeup ? the mscan12 will function normally. 1 = sleep request ? the mscan 12 will go into sleep mode. sftres ? soft-reset bit when this bit is set by the cpu, the ms can12 immediately enters the soft-reset state. any on-going transmission or reception is aborted and synchronization to the bus is lost. these registers will go into and stay in the same state as out of hard reset: cmcr0, crflg, crier, ctflg, and ctcr. registers cmcr1, cbtr0, cbtr1, cidac, cidar0?cidar7, and cidmr0?cidmr7 can be written only by the cpu when the mscan12 is in soft-reset state. the values of the error counters are not affected by soft reset. when this bit is cleared by the cpu, the mscan12 will try to synchronize to the can bus. for example, if the mscan12 is not in bus-off state, it will be synchronized after 11 recessive bits on the bus; if the mscan12 is in bus-off state, it continues to wait for 128 occurrences of 11 recessive bits. clearing sftres and writing to other bits in cmcr0 must be in separate instructions. 0 = normal operation 1 = mscan12 in soft-reset state
mscan12 controller data sheet m68hc12b family ? rev. 9.0 286 mscan12 controller motorola 16.12.2 mscan12 module control register 1 loopb ? loop back self-test mode bit when this bit is set, the mscan12 performs an internal loop back which can be used for self-test operation. the bit stream output of the transmitter is fed back to the receiver. the rxcan input pin is ignored and the txcan output goes to the recessive state (1). in this state the mscan12 ignores the bit sent during the ack slot of the can frame acknowledge fi eld to ensure proper reception of its own message. both transmit and receive interrupts are generated. 0 = normal operation 1 = activate loop back self-test mode note: the ack bit is added to the can frame by the protocol. for more information on the can frame and the ack bit, refer to the bosch can 2.0 specification. wupm ? wakeup mode flag this flag defines whether the integrated lo w-pass filter is applied to protect the mscan12 from spurious wakeups. see 16.7.4 programmable wakeup function . 0 = mscan12 will wake up the cpu after any recessive-to- dominant edge on the can bus. 1 = mscan12 will wake up the cpu only in the case of a dominant pulse on the bus which has a length of approximately t wup . clksrc ? mscan12 clock source flag this flag defines which clock source t he mscan12 module is driven from (only for system with cgm module. see 16.9 clock system and figure 16-7 . 0 = mscan12 clock source is extali. 1 = mscan12 clock source is twice the frequency of eclk. note: the cmcr1 register can be written only if the sftres bit in cmcr0 is set. address: $0101 bit 7654321bit 0 read:00000 loopb wupm clksrc write: reset:00000000 = unimplemented figure 16-17. mscan12 module control register 1 (cmcr1)
mscan12 controller programmer?s model of control registers m68hc12b family ? rev. 9.0 data sheet motorola mscan12 controller 287 16.12.3 mscan12 bus timing register 0 sjw1 and sjw0 ? synchronization jump width bits the synchronization jump width defines the maximum number of time quanta (tq) clock cycles by which a bit may be shortened, or lengthened, to achieve resynchronization on data transitions on the bus (see table 16-5 ). brp5?brp0 ? baud rate prescaler bits these bits determine the time quanta (tq) clock, which is used to build up the individual bit timing, according to table 16-6 . note: the cbtr0 register can be written only if the sftres bit in cmcr0 is set. address: $0102 bit 7654321bit 0 read: sjw1 sjw0 brp5 brp4 bpr3 bpr2 bpr1 bpr0 write: reset:00000000 figure 16-18. mscan12 bus timing register 0 (cbtr0) table 16-5. synchronization jump width sjw1 sjw0 synchronization jump width 0 0 1 tq clock cycle 0 1 2 tq clock cycles 1 0 3 tq clock cycles 1 1 4 tq clock cycles table 16-6. baud rate prescaler brp5 brp4 brp3 brp2 brp1 brp0 prescaler value (p) 000000 1 000001 2 000010 3 000011 4 :::::: : 111111 64
mscan12 controller data sheet m68hc12b family ? rev. 9.0 288 mscan12 controller motorola 16.12.4 mscan12 bus timing register 1 samp ? sampling bit this bit determines the number of samples of the serial bus to be taken per bit time. if set, three samples per bit are ta ken, the regular one (sample point) and two preceding samples, using a majority rule. for higher bit rates, samp should be cleared, which means that only one sample will be taken per bit. 0 = one sample per bit 1 = three samples per bit. (1) tseg22?tseg10 ? time segment bits time segments within the bit time fix the number of clock cycles per bit time and the location of the sample point. see figure 16-8 . address: $0103 bit 7654321bit 0 read: samp tseg22 tseg21 tseg20 tseg13 tseg12 tseg11 tseg10 write: reset:00000000 figure 16-19. mscan12 bus timing register 1 (cbtr1) 1. in this case, phase_seg1 must be at least two times quanta. table 16-7. time segment syntax sync_seg system expects transitions to occur on the bus during this period. transmit point a node in transmit mode will transfer a new value to the can bus at this point. sample point a node in receive mode will sample the bus at this point. if the three samples per bit option is selected, then this point marks the position of the third sample.
mscan12 controller programmer?s model of control registers m68hc12b family ? rev. 9.0 data sheet motorola mscan12 controller 289 time segment 1 (tseg1) and time s egment 2 (tseg2) are programmable as shown in table 16-8 . the bit time is determined by the oscillat or frequency, the baud rate prescaler, and the number of time quanta (tq) clock cycles per bit (as shown in table 16-8 ). note: the cbtr1 register can be written only if the sftres bit in cmcr0 is set. 16.12.5 mscan12 receiver flag register all bits of this register are read and clear only. a flag can be cleared by writing a 1 to the corresponding bit position. a flag can be cleared only when the condition which caused the setting is valid no longer . writing a 0 has no effect on the flag setting. every flag has an associated interr upt enable flag in the crier register. a hard or soft reset will clear the register. table 16-8. time segment values tseg13 tseg12 tseg11 tseg10 time segment 1 0 0 0 0 1 tq clock cycle 0 0 0 1 2 tq clock cycles 0 0 1 0 3 tq clock cycles 0 0 1 1 4 tq clock cycles .... . 1 1 1 1 16 tq clock cycles tseg22 tseg21 tseg20 time segment 2 0 0 0 1 tq clock cycle 0 0 1 2 tq clock cycles ... . 1 1 1 8 tq clock cycles bittime presc value t f cgmcanclk --------------------------------------- number ? of timequanta tt = address: $0104 bit 7654321bit 0 read: wupif rwrnif twrnif rerrif terrif boffif ovrif rxf write: reset:00000000 figure 16-20. mscan12 receiver flag register (crflg)
mscan12 controller data sheet m68hc12b family ? rev. 9.0 290 mscan12 controller motorola wupif ? wakeup interrupt flag if the mscan12 detects bus activity while in sleep mode, it sets the wupif flag. if not masked, a wakeup interrupt is pending while this flag is set. 0 = no wakeup activity has be en observed while in sleep mode. 1 = mscan12 has detected activity on the bus and requested wakeup. rwrnif ? receiver warning interrupt flag this flag is set when the mscan12 goes in to warning status due to the receive error counter (rec) exceeding 96 and neither one of the error interrupt flags nor the bus-off interrupt flag is set (1) . if not masked, an error interrupt is pending while this flag is set. 0 = no receiver warning status has been reached. 1 = mscan12 went into receiver warning status. twrnif ? transmitter warning interrupt flag this bit will be set when the mscan12 goes into warning status due to the transmit error counter (tec) exceeding 96 and neither one of the error interrupt flags nor the bus-off interrupt flag is set (2) . if not masked, an e rror interrupt is pending while this flag is set. 0 = no transmitter warning status has been reached. 1 = mscan12 went into transmitter warning status. rerrif ? receiver error passive interrupt flag this flag is set when the mscan12 goes into error passive status due to the receive error counter (rec) exceeding 127 and the bus-off interrupt flag is not set (3) . if not masked, an error interrupt is pending while this flag is set. 0 = no receiver error passive status has been reached. 1 = mscan12 went into receiver error passive status. terrif ? transmitter error passive interrupt flag this flag is set when the mscan12 goes into error passive status due to the transmit error counter (tec) exceeding 127 and the bus-off interrupt flag is not set (4) . if not masked, an error interrupt is pending while this flag is set. 0 = no transmitter error passive status has been reached. 1 = mscan12 went into transmitter error passive status. boffif ? bus-off interrupt flag this flag is set when the mscan12 goes in to bus-off status, due to the transmit error counter exceeding 255. it cannot be cleared before the mscan12 has monitored 128 times 11 consecutive rece ssive bits on the bus. if not masked, an error interrupt is pending while this flag is set. 0 = no bus-off status has been reached. 1 = mscan12 went into bus-off status. 1. condition to set the flag: rwrnif = (96 rec 127) & rerrif & terrif & boffif 2. condition to set t he flag: twrnif = (96 tec 127) & rerrif & terrif & boffif 3. condition to set t he flag: rerrif = (128 rec 255) & boffif 4. condition to set the flag: terrif = (128 tec 255) & boffif
mscan12 controller programmer?s model of control registers m68hc12b family ? rev. 9.0 data sheet motorola mscan12 controller 291 ovrif ? overrun interrupt flag this flag is set when a data overrun condition occurs. if not masked, an error interrupt is pending while this flag is set. 0 = no data overrun has occurred. 1 = a data overrun has been detected. rxf ? receive buffer full flag the rxf flag is set by the mscan12 wh en a new message is available in the foreground receive buffer. this flag indi cates whether the buffer is loaded with a correctly received message. after the cpu has read that message from the receive buffer, the rxf flag must be handshaken (cleared) to release the buffer. a set rxf flag prohibits the exchange of the background receive buffer into the foreground buffer. if not masked, a receive interrupt is pending while this flag is set. 0 = receive buffer is released (not full). 1 = receive buffer is full. a new message is available. note: to ensure data integrity, no registers of the receive buffer shall be read while the rxf flag is cleared.the crflg register is held in the reset state when the sftres bit in cmcr0 is set. 16.12.6 mscan12 receiver interrupt enable register wupie ? wakeup interrupt enable bit 0 = no interrupt is generated from this event. 1 = a wakeup event results in a wakeup interrupt. rwrnie ? receiver warning interrupt enable bit 0 = no interrupt is generated from this event. 1 = a receiver warning status event results in an error interrupt. twrnie ? transmitter warning interrupt enable bit 0 = no interrupt is generated from this event. 1 = a transmitter warning status event results in an error interrupt. rerrie ? receiver error passive interrupt enable bit 0 = no interrupt is generated from this event. 1 = a receiver error passive status event results in an error interrupt. terrie ? transmitter error passive interrupt enable bit 0 = no interrupt is generated from this event. 1 = a transmitter error passive status event results in an error interrupt. address: $0105 bit 7654321bit 0 read: wupie rwrnie twrnie rerrie terrie boffie ovrie rxfie write: reset:00000000 figure 16-21. mscan12 receiver interrupt enable register (crier)
mscan12 controller data sheet m68hc12b family ? rev. 9.0 292 mscan12 controller motorola boffie ? bus-off interrupt enable bit 0 = no interrupt is generated from this event. 1 = a bus-off event results in an error interrupt. ovrie ? overrun interrupt enable bit 0 = no interrupt is generated from this event. 1 = an overrun event results in an error interrupt. rxfie ? receiver full interrupt enable bit 0 = no interrupt is generated from this event. 1 = a receive buffer full (successful message reception) event results in a receive interrupt. note: the crier register is held in the reset state when the sftres bit in cmcr0 is set. 16.12.7 mscan12 transmitter flag register the abort acknowledge flags are read only. the transmitter buffer empty flags are read and clear only. a flag can be cleared by writing a 1 to the corresponding bit position. writing a 0 has no effect on the flag setting. each transmitter buffer empty flag has an associated interrupt enable bit in the ctcr register. a hard or soft reset resets the register. abtak2?abtak0 ? abort acknowledge flag this flag acknowledges that a me ssage has been aborted due to a pending abort request from the cpu. after a particular message buffer has been flagged empty, this flag can be used by the application software to identify whether the message has been aborted successfully or has been sent in the meantime. the abtakx flag is cleared implicitly when ever the corresponding txe flag is cleared. 0 = the message has not been aborted; it has been sent. 1 = the message has been aborted. txe2?txe0 ?transmitter buffer empty flag this flag indicates that the associated transmit message buffer is empty, thus not scheduled for transmission. the cpu mu st handshake (clear) the flag after a message has been set up in the transmit buffer and is due for transmission. the mscan12 sets the flag after the message has been sent successfully. the flag is also set by the mscan12 when the transmission request was aborted address: $0106 bit 7654321bit 0 read: 0 abtak2 abtak1 abtak0 0 txe2 txe1 txe0 write: reset:00000111 = unimplemented figure 16-22. mscan12 transmitter flag register (ctflg)
mscan12 controller programmer?s model of control registers m68hc12b family ? rev. 9.0 data sheet motorola mscan12 controller 293 successfully due to a pending abort request. see 16.12.8 mscan12 transmitter control register . if not masked, a transmit interrupt is pending while this flag is set. clearing a txex flag also clears the corresponding abtakx flag. when a txex flag is set, the corresponding abt rqx bit is cleared. see 16.12.8 mscan12 transmitter control register . 0 = the associated message buffer is full (loaded with a message due for transmission). 1 = the associated message buffer is empty (not scheduled). note: to ensure data integrity, no registers of the transmit buffers should be written to while the associated txe flag is cleared.the ctflg register is held in the reset state if the sftres bit cmcr0 is set. 16.12.8 mscan12 transmitter control register abtrq2?abtrq0 ? abort request bits the cpu sets an abtrqx bit to request that a scheduled message buffer (txex = 0) shall be aborted. the mscan12 grants the request if the message has not already started transmission, or if the transmission is not successful (lost arbitration or error). when a message is aborted, the associated txe and the abort acknowledge flag (abtak) (see 16.12.7 mscan12 transmitter flag register ) are set and an txe interrupt is generated if enabled. the cpu cannot reset abtrqx. abtrqx is cleared implicit ly whenever the associated txe flag is set. 0 = no abort request 1 = abort request pending note: the software must not clear one or more of the txe flags in ctfgl and simultaneously set the respective abtrq bit(s). txeie2?txeie0 ? transmitter empty interrupt enable bits 0 = no interrupt will be generated from this event. 1 = a transmitter empty (transmit buffer available for transmission) event will result in a transmitter empty interrupt. note: the ctcr register is held in the reset state when the sftres bit in cmcr0 is set. address: $0107 bit 7654321bit 0 read: 0 abtrq2 abtrq1 abtrq0 0 txeie2 txeie1 txeie0 write: reset:00000000 = unimplemented figure 16-23. mscan12 transmitter control register (ctcr)
mscan12 controller data sheet m68hc12b family ? rev. 9.0 294 mscan12 controller motorola 16.12.9 mscan12 identifier acceptance control register idam1 and idam0? identifier acceptance mode flags the cpu sets these flags to define the id entifier acceptance filter organization. see 16.4 identifier acceptance filter . table 16-8 summarizes the different settings. in filter closed mode, no messages are accepted so that the foreground buffer is never reloaded. idhit2?idhit0? identifier acceptance hit indicator flags the mscan12 sets these flags to indi cate an identifier acceptance hit. see 16.4 identifier acceptance filter . table 16-8 summarizes the different settings. the idhit indicators are always related to the message in the foreground buffer. when a message gets copied from the background to the foreground buffer, the indicators are updated as well. note: the cidac register can be written only if the sftres bit in cmcr0 is set. address: $0108 bit 7654321bit 0 read: 0 0 idam1 idam0 0 idhit2 idhit1 idhit0 write: reset:00000000 = unimplemented figure 16-24. mscan12 identifier acceptance control register (cidac) table 16-9. identifier acceptance mode settings idam1 idam0 identifier acceptance mode 0 0 two 32-bit acceptance filters 0 1 four 16-bit acceptance filters 1 0 eight 8-bit acceptance filters 1 1 filter closed table 16-10. identifier acceptance hit indication idhit2 idhit1 idhit0 iden tifier acceptance hit 0 0 0 filter 0 hit 0 0 1 filter 1 hit 0 1 0 filter 2 hit 0 1 1 filter 3 hit 1 0 0 filter 4 hit 1 0 1 filter 5 hit 1 1 0 filter 6 hit 1 1 1 filter 7 hit
mscan12 controller programmer?s model of control registers m68hc12b family ? rev. 9.0 data sheet motorola mscan12 controller 295 16.12.10 mscan12 receive error counter this register reflects the status of the mscan12 receive error counter. the register is read only. 16.12.11 mscan12 transmit error counter this register reflects the status of the mscan12 transmit error counter. the register is read only. note: both error counters may be read only when in sleep or soft-reset mode. 16.12.12 mscan12 identifier acceptance registers on reception, each message is written into the background receive buffer. the cpu is only signalled to read the message if it passes the criteria in the identifier acceptance and identifier mask registers (accepted); otherwise, the message will be overwritten by the next message (dropped). the acceptance registers of the mscan12 are applied on the idr0 to idr3 registers of incoming messages in a bit-by-bit manner. for extended identifiers, all four accept ance and mask registers are applied. for standard identifiers only the first two (cidmr0/cidmr1 and cidar0/cidar1) are applied. address: $010e bit 7654321bit 0 read: rxerr7 rxerr6 rxerr5 rxerr4 rxerr3 rxerr2 rxerr1 rxerr0 write: reset:00000000 = unimplemented figure 16-25. mscan12 receive error counter (crxerr) address: $010f bit 7654321bit 0 read: txerr7 txerr6 txerr5 txerr4 txerr3 txerr2 txerr1 txerr0 write: reset:00000000 = unimplemented figure 16-26. mscan12 transmit error counter (ctxerr)
mscan12 controller data sheet m68hc12b family ? rev. 9.0 296 mscan12 controller motorola address: $0110 bit 7654321bit 0 read: ac7ac6ac5ac4ac3ac2ac1ac0 write: reset: unaffected by reset address: $0111 bit 7654321bit 0 read: ac7ac6ac5ac4ac3ac2ac1ac0 write: reset: unaffected by reset address: $0112 bit 7654321bit 0 read: ac7ac6ac5ac4ac3ac2ac1ac0 write: reset: unaffected by reset address: $0113 bit 7654321bit 0 read: ac7ac6ac5ac4ac3ac2ac1ac0 write: reset: unaffected by reset figure 16-27. first bank mscan12 identifier acceptance registers (cidar0?cidar3) address: $0118 bit 7654321bit 0 read: ac7ac6ac5ac4ac3ac2ac1ac0 write: reset: unaffected by reset address: $0119 bit 7654321bit 0 read: ac7ac6ac5ac4ac3ac2ac1ac0 write: reset: unaffected by reset address: $011a bit 7654321bit 0 read: ac7ac6ac5ac4ac3ac2ac1ac0 write: reset: unaffected by reset address: $011b bit 7654321bit 0 read: ac7ac6ac5ac4ac3ac2ac1ac0 write: reset: unaffected by reset figure 16-28. second bank mscan12 identifier acceptance registers (cidar4?cidar7)
mscan12 controller programmer?s model of control registers m68hc12b family ? rev. 9.0 data sheet motorola mscan12 controller 297 ac7?ac0 ? acceptance code bits ac7?ac0 comprise a user-defined sequence of bits with which the corresponding bits of the related identifier register (idrn) of the receive message buffer are compared. the result of this comparison is then masked with the corresponding identifier mask register. note: the cidar0-cidar7 registers can be writt en only if the sftres bit in cmcr0 is set. 16.12.13 mscan12 identifier mask registers the identifier mask register specifies which of the corresponding bits in the identifier acceptance register are relevant for acceptance filtering. to receive standard identifiers in 32-bit filter mode, the last three bits (am2?am0) in the mask registers cidmr1 and cidmr5 must be programmed to don?t care. to receive standard identifiers in 16 bit filter mode the last three bits (am2?am0) in the mask registers cidmr1, cidmr3, cidmr5, and cidmr7 must be programmed to don?t care. address: $0114 bit 7654321bit 0 read: am7 am6 am5 am4 am3 am2 am1 am0 write: reset: unaffected by reset address: $0115 bit 7654321bit 0 read: am7 am6 am5 am4 am3 am2 am1 am0 write: reset: unaffected by reset address: $0116 bit 7654321bit 0 read: am7 am6 am5 am4 am3 am2 am1 am0 write: reset: unaffected by reset address: $0117 bit 7654321bit 0 read: am7 am6 am5 am4 am3 am2 am1 am0 write: reset: unaffected by reset figure 16-29. first bank mscan12 identifier mask registers (cidmr0?cidmr3)
mscan12 controller data sheet m68hc12b family ? rev. 9.0 298 mscan12 controller motorola am7?am0 ? acceptance mask bits if a particular bit in this register is cl eared, this indicates that the corresponding bit in the identifier acceptance register must be the same as its identifier bit before a match will be detected. the mess age will be accepted if all such bits match. if a bit is set, it indicates that the state of the corresponding bit in the identifier acceptance register will not a ffect whether or not the message is accepted. 1 = ignore corresponding acceptance code register bit. 0 = match corresponding acceptance code register and identifier bits. note: the cidmr0?cidmr7 registers can be wr itten only if the sftres bit in cmcr0 is set. address: $011c bit 7654321bit 0 read: am7 am6 am5 am4 am3 am2 am1 am0 write: reset: unaffected by reset address: $011d bit 7654321bit 0 read: am7 am6 am5 am4 am3 am2 am1 am0 write: reset: unaffected by reset address: $011e bit 7654321bit 0 read: am7 am6 am5 am4 am3 am2 am1 am0 write: reset: unaffected by reset address: $011f bit 7654321bit 0 read: am7 am6 am5 am4 am3 am2 am1 am0 write: reset: unaffected by reset figure 16-30. second bank mscan12 identifier mask registers (cidmr4?cidmr7)
mscan12 controller programmer?s model of control registers m68hc12b family ? rev. 9.0 data sheet motorola mscan12 controller 299 16.12.14 mscan12 port can control register these bits control pins 7?2 of port can control register. pins 1 and 0 are reserved for the rxcan (input only) and txcan (output only) pins. puecan ? pullup enable port can bit 0 = pull mode disabled for port can 1 = pull mode enabled for port can rdpcan ? reduced drive port can 0 = reduced drive disabled for port can 1 = reduced drive enabled for port can 16.12.15 mscan12 port can data register pcan7?pcan2 ? port can data bits writing to pcanx stores the bit value in an internal bit memory. this value is driven to the respective pin only if ddrcanx = 1. reading pcanx returns:  value of the internal bit memory driven to the pin, if ddrcanx = 1  value of the respective pin, if ddrcanx = 0 reading bits 1 and 0 returns the value of the txcan and rxcan pins, respectively. address: $013d bit 7654321bit 0 read:000000 puecan rdpcan write: reset:00000000 = unimplemented figure 16-31. mscan12 port can control register (pctlcan) address: $013e bit 7654321bit 0 read: pcan7 pcan6 pcan5 pcan4 pcan2 pcan2 txcan rxcan write: reset: unaffected by reset = unimplemented figure 16-32. mscan12 port can data register (portcan)
mscan12 controller data sheet m68hc12b family ? rev. 9.0 300 mscan12 controller motorola 16.12.16 mscan12 port can data direction register ddrcan7?ddrcan2 ? data direction port can bits 0 = respective input/output (i/o ) pin is configured for input. 1 = respective i/o pin is configured for output. address: $013f bit 7654321bit 0 read: ddrcan7 ddrcan6 ddrcan5 ddrcan4 ddrcan3 ddrcan2 00 write: reset:00000000 = unimplemented figure 16-33. mscan12 port can data direction register (ddrcan)
m68hc12b family ? rev. 9.0 data sheet motorola analog-to-digital converter (atd) 301 data sheet ? m68hc12b family section 17. analog-to-dig ital converter (atd) 17.1 introduction the atd is an 8-channel, 10-bit, multip lexed-input, successive-approximation, analog-to-digital converter, accurate to 2 least significant bit (lsb). it does not require external sample and hold circ uits because of the type of charge redistribution technique used. the atd co nverter timing is synchronized to the system p clock. the atd module consists of a 16-word (32-byte) memory-mapped control register block used for control, testing, and configuration. 17.2 functional description a single conversion sequence consists of four or eight conversions, depending on the state of the select 8-channel mode (s8cm) bit when atdctl5 is written. there are eight basic conversion modes. in the non-scan modes, the scf bit is set after the sequence of four or eight conversions has been performed and the atd module halts. in the scan modes, the scf bit is set after the first sequence of four or eight conversions has been performed, and the atd module continues to restart the sequence. in both modes, the ccf bit as sociated with each register is set when that register is loaded with the appropriat e conversion result. that flag is cleared automatically when that result register is read. the conversions are started by writing to the control registers.
analog-to-digital converter (atd) data sheet m68hc12b family ? rev. 9.0 302 analog-to-digital converter (atd) motorola figure 17-1. atd block diagram atd0 sar rc dac array and comparator v dda v ssa v rl v rh analog mux and sample buffer an7/pad7 an6/pad6 an5/pad5 an4/pad4 an3/pad3 an2/pad2 an1/pad1 an0/pad0 atd1 atd2 atd3 atd4 atd5 atd6 atd7 mode and timing control clock select/prescale port ad data input register amplifier internal bus
analog-to-digital converter (atd) atd registers m68hc12b family ? rev. 9.0 data sheet motorola analog-to-digital converter (atd) 303 17.3 atd registers this section describes the atd registers. 17.3.1 atd control register 0 read: anytime write: anytime note: writes to this register abort the current conversion sequence. 17.3.2 atd control register 1 read: special mode only write: has no meaning 17.3.3 atd control register 2 read: anytime write: anytime except ascif bit, which cannot be written address: $0060 bit 7654321bit 0 read: 00000000 write: reset:00000000 figure 17-2. atd control register 0 (atdctl0) address: $0061 bit 7654321bit 0 read: 00000000 write: reset:00000000 figure 17-3. reserved (atdctl1) address: $0062 bit 7654321bit 0 read: adpu affc awai 000 ascie ascif write: reset:00000000 = unimplemented figure 17-4. atd control register 2 (atdctl2)
analog-to-digital converter (atd) data sheet m68hc12b family ? rev. 9.0 304 analog-to-digital converter (atd) motorola the atd control register 2 (atdctl2) is used to select the power-up mode, interrupt control, and freeze control. note: writing to this register aborts the current conversion sequence. adpu ? atd disable bit software can disable the clock signal to the atd and power down the analog circuits to reduce power consumption. when reset to 0, the adpu bit aborts any conversion sequence in progress. bec ause the bias currents to the analog circuits are turned off, the atd requires a pe riod of recovery time to stabilize the analog circuits after setting the adpu bit. 0 = disables the atd, including the analog section for reduction in power consumption 1 = allows the atd to function normally affc ? atd fast flag clear bit 0 = atd flag clearing operates normally (read the status register before reading the result register to clear the associated ccf bit). 1 = changes all atd conversion complete flags to a fast clear sequence. any access to a result register (atd0? atd7) will cause the associated ccf flag to clear automatically if it was set at the time. awai ? atd stop in wait mode bit 0 = atd continues to run when the mcu is in wait mode. 1 = atd stops to save power when the mcu is in wait mode. ascie ? atd sequence complete interrupt enable bit 0 = disables atd interrupt 1 = enables atd interrupt on sequence complete ascif ? atd sequence complete interrupt flag cannot be written in any mode. 0 = no atd interrupt occurred 1 = atd sequence complete 17.3.4 adt control register 3 read: anytime write: anytime address: $0063 bit 7654321bit 0 read:000000 frz1 frz0 write: reset:00000000 = unimplemented figure 17-5. atd control register 3 (atdctl3)
analog-to-digital converter (atd) atd registers m68hc12b family ? rev. 9.0 data sheet motorola analog-to-digital converter (atd) 305 the atd control register 3 (atdctl3) is used to select the power-up mode, interrupt control, and freeze control. note: writing to this register aborts any cu rrent conversion sequence and suspends module operation at breakpoint. frz1 and frz0 ? background debug (freeze) enable bits when debugging an application, it is useful in many cases to have the atd pause when a breakpoint is encountered. these two bits determine how the atd will respond when background debug mode becomes active. see table 17-1 . 17.3.5 atd control register 4 the atd control register 4 (atdctl4) selects the clock source and sets up the prescaler. writes to the atd control registers initiate a new conversion sequence. if a write occurs while a c onversion is in progress, t he conversion is aborted and atd activity halts until a write to atdctl5 occurs. s10bm ? atd 10-bit mode control bit 0 = 8-bit operation 1 = 10-bit operation smp1 and smp0 ? select sample time bits these bits are used to select one of four sample times after the buffered sample and transfer has occurred. see table 17-2 . table 17-1. atd response to background debug enable frz1 frz0 atd response 0 0 continue conversions in active background mode 01reserved 1 0 finish current conversion, then freeze 1 1 freeze when bdm is active address: $0064 bit 7654321bit 0 read: s10bm smp1 smp0 prs4 prs3 prs2 prs1 prs0 write: reset:00000001 figure 17-6. atd control register 4 (atdctl4)
analog-to-digital converter (atd) data sheet m68hc12b family ? rev. 9.0 306 analog-to-digital converter (atd) motorola prs4?prs0 ? select divide-by factor for atd p-clock prescaler bits the binary value written to these bits (1 to 31) selects the divide-by factor for the modulo counter-based prescaler. the p clock is divided by this value plus one, and then fed into a divide-by-two circuit to generate the atd module clock. the divide-by-two circuit ensures symmetry of the output clock signal. clearing these bits causes the prescale value to default to 1 which results in a divide-by-two prescale factor. this signal is then fed into the divide-by-two logic. the reset state divides the p clock by a total of four and is appropriate for nominal operation at a bus rate of between 2 mhz and 8 mhz. table 17-3 shows the divide-by operation and the appropriate range of system clock frequencies. table 17-2. final sample time selection smp1 smp0 final sample time total 8-bit conversion time total 10-bit conversion time 0 0 2 atd clock periods 18 atd clock periods 20 atd clock periods 0 1 4 atd clock periods 20 atd clock periods 22 atd clock periods 1 0 8 atd clock periods 24 atd clock periods 26 atd clock periods 1 1 16 atd clock periods 32 atd clock periods 34 atd clock periods table 17-3. clock prescaler values prescale value total divisor max p clock (1) 1. maximum conversion frequency is 2 mhz. maximum p clock divisor value becomes maximum conversion rate that can be used on this atd module. min p clock (2) 2. minimum conversion frequency is 500 khz. minimum p clock divisor value becomes minimum conversion rate that this atd can perform. 00000 2 4 mhz 1 mhz 00001 4 8 mhz 2 mhz 00010 6 8 mhz 3 mhz 00011 8 8 mhz 4 mhz 00100 10 8 mhz 5 mhz 00101 12 8 mhz 6 mhz 00110 14 8 mhz 7 mhz 00111 16 8 mhz 8 mhz 01xxx do not use 1xxxx
analog-to-digital converter (atd) atd registers m68hc12b family ? rev. 9.0 data sheet motorola analog-to-digital converter (atd) 307 17.3.6 atd control register 5 read: anytime write: anytime the atd control register 5 is used to se lect the conversion modes, the conversion channel(s), and initiate conversions. a write to atdctl5 initiates a new conversion sequence. if a conversion sequence is in progress when a write occurs, that sequence is aborted and the scf and ccf bits are reset. s8cm ? select 8 channel mode bit 0 = conversion sequence cons ists of four conversions. 1 = conversion sequence consists of eight conversions. scan ? enable continuous channel scan bit when a conversion sequence is initiated by a write to the atdctl register, the user has a choice of performing a sequence of four (or eight, depending on the s8cm bit) conversions or continuously performing four (or eight) conversion sequences. 0 = single conversion sequence 1 = continuous conver sion sequences (scan mode) mult ? enable multichannel conversion bit 0 = atd sequencer runs all f our or eight conversions on a single input channel selected via the cd, cc, cb, and ca bits. 1 = atd sequencer runs each of the four or eight conversions on sequential channels in a specific group. refer to table 17-4 . cd, cc, cb, and ca ? channel select for conversion bits address: $0065 bit 7654321bit 0 read: s8cm scan mult cd cc cb ca write: reset:00000000 = unimplemented figure 17-7. atd control register 5 (atdctl5)
analog-to-digital converter (atd) data sheet m68hc12b family ? rev. 9.0 308 analog-to-digital converter (atd) motorola table 17-4. multichannel mode result register assignment s8cm cd cc cb ca channel signal result in adrx if mult = 1 000 0 0an0 adr0 0 1an1 adr1 1 0an2 adr2 1 1an3 adr3 001 0 0an4 adr0 0 1an5 adr1 1 0an6 adr2 1 1an7 adr3 010 0 0reserved adr0 0 1reserved adr1 1 0reserved adr2 1 1reserved adr3 011 0 0 v rh adr0 0 1 v rl adr1 1 0 (v rh + v rl )/2 adr2 1 1test/reserved adr3 10 0 0 0an0 adr0 0 0 1an1 adr1 0 1 0an2 adr2 0 1 1an3 adr3 1 0 0an4 adr4 1 0 1an5 adr5 1 1 0an6 adr6 1 1 1an7 adr7 11 0 0 0reserved adr0 0 0 1reserved adr1 0 1 0reserved adr2 0 1 1reserved adr3 1 0 0 v rh adr4 1 0 1 v rl adr5 1 1 0 (v rh + v rl )/2 adr6 1 1 1test/reserved adr7 shaded bits are ?don?t care? if mult = 1 and the entire block of four or eight channels makes up a conversion sequence. when mult = 0, al l four bits (cd, cc, cb, and ca) must be specified and a conversion sequence consists of four or eight consecutive conversions of the single specified channel.
analog-to-digital converter (atd) atd registers m68hc12b family ? rev. 9.0 data sheet motorola analog-to-digital converter (atd) 309 17.3.7 atd status registers read: normally anytime write: in special mode, the scf bit and the ccf bits may also be written. the atd status registers contain the flags indicating the completion of atd conversions. scf ? sequence complete flag this bit is set at the end of the conversion sequence w hen in the single conversion sequence mode (scan = 0 in atdctl5) and is set at the end of the first conversion sequence when in the continuous conversion mode (scan = 1 in atdctl5). when affc = 0, scf is cleared when a write is performed to atdctl5 to initiate a new conversion sequence. when affc = 1, scf is cleared after the first result register is read. cc2?cc0 ? conversion counter bits for current 4 or 8 conversions this 3-bit value reflects the contents of the conversion counter pointer in a four or eight count sequence. this value also re flects which result register is written next, indicating which channel is currently being converted. ccf7?ccf0 ? conversion complete flags each ccf bit is associated with an individual atd result register. for each register, this bit is set at the end of conversion for the associated atd channel and remains set until that atd result register is read. it is cleared at that time if affc bit is set, regardless of whether a status register read has been performed (for example, a status register read is not a pre-qualifier for the clearing mechanism when affc = 1). otherwise, the status register must be read to clear the flag. address: $0066 bit 7654321bit 0 read:scf0000cc2cc1cc0 write: reset:00000000 address: $0067 bit 7654321bit 0 read: ccf7 ccf6 ccf5 ccf4 ccf3 ccf2 ccf1 ccf0 write: reset:00000000 = unimplemented figure 17-8. atd status register (atdstat)
analog-to-digital converter (atd) data sheet m68hc12b family ? rev. 9.0 310 analog-to-digital converter (atd) motorola 17.3.8 atd test registers read: special modes only write: special modes only the test registers control various special modes which are used during manufacturing. in the normal modes, reads of the test register return 0 and writes have no effect. sar9?sar0 ? sar data bits reads of this byte return the current value in the sar. writes to this byte change the sar to the value written. bits sar9?sar0 reflect the 10 sar bits used during the resolution process for an 10-bit result. rst ? module reset bit when set, this bit causes all registers and activity in the module to assume the same state as out of power-on reset (except for adpu bit in atdctl2, which remains set, allowing the atd module to remain enabled). tstout ? multiplex output of tst3?tst0 (factory use) tst3?tst0 ? test bits 3 to 0 (reserved) selects one of 16 reserved factory testing modes address: $0068 bit 7654321bit 0 read: sar9 sar8 sar7 sar6 sar5 sar4 sar3 sar2 write: reset:00000000 address: $0069 bit 7654321bit 0 read: sar1 sar0 rst tstout tst3 tst2 tst1 tst0 write: reset:00000000 figure 17-9. atd test register (atdstat)
analog-to-digital converter (atd) atd registers m68hc12b family ? rev. 9.0 data sheet motorola analog-to-digital converter (atd) 311 17.3.9 port ad data input register read: anytime write: has no meaning or effect pad7?pad0 ? port ad data input bits after reset, these bits reflect the state of the input pins. pad7?pad0 may be used for general-purpose digital input. when the software reads portad, it obtains the digital levels that appear on the corresponding port ad pins. pins with signals not meeting v il or v ih specifications will have an indeterminate value. 17.3.10 atd result registers address: $006f bit 7654321bit 0 read: pad7 pad6 pad5 pad4 pad3 pad2 pad1 pad0 write: reset: after reset, reflect the state of the inputs pins = unimplemented figure 17-10. port ad data input register (portad) adrx0h: adrx1h: adrx2h: adrx3h: adrx4h: adrx5h: adrx6h: adrx7h: $0070 $0072 $0074 $0076 $0078 $007a $007c $007e bit 7654321bit 0 read: bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 write: reset: undefined = unimplemented figure 17-11. atd result registers high
analog-to-digital converter (atd) data sheet m68hc12b family ? rev. 9.0 312 analog-to-digital converter (atd) motorola read: anytime write: has no meaning or effect adrxh[15:8]?adrxh[7:0] ? atd conversion result bits the reset condition for these registers is undefined. these bits contain the left-justified, unsigned result from the atd conversion. the channel from which this result was obtained is dependant on the conversion mode selected. these registers are al ways read-only in normal mode. 17.4 atd mode operation stop causes all clocks to halt (if the s bit in the ccr is 0). the system is placed in a minimum-power standby mode. this aborts any conversion sequence in progress. during stop recovery, the at d must delay for the stop recovery time (t sr ) before initiating a new atd conversion sequence. wait atd conversion continues unless the awai bit in atdctl2 register is set. bdm debug options available as set in register atdctl3. user atd continues running unless adpu is cleared. adpu atd operations are stopped if adpu = 0, but registers are accessible. adrx0l: adrx1l: adrx2l: adrx3l: adrx4l: adrx5l: adrx6l: adrx7l: $0071 $0073 $0075 $0077 $0079 $007b $007d $007f bit 7654321bit 0 read: bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 write: reset: undefined = unimplemented figure 17-12. atd result registers low
analog-to-digital converter (atd) using the atd to measure a potentiometer signal m68hc12b family ? rev. 9.0 data sheet motorola analog-to-digital converter (atd) 313 17.5 using the atd to me asure a potentiometer signal this exercise allows the student to utilize the atd on the hc12 to measure a potentiometer signal output routed from the udlp1 board to the hc12 atd pin pad6. first the atdctl registers are initialized. a delay loop of 100 s is then executed. the resolution is set up followed by a conversion set up on channel 6. after waiting for the status bit to set, the result goes to the d accumulator. if the program is working properly, a different value should be found in the d accumulator as the left potentiometer is varied for each execution of the program. 17.5.1 equipment for this exercise, use the m68hc912b32evb emulation board. 17.5.2 code listing note: a comment line is deliminted by a semi-c olon. if there is no code before comment, an ?;? must be placed in the first colu mn to avoid assembly errors. ; ---------------------------------------------------------------------- ; main program ; ---------------------------------------------------------------------- org $7000 ; 16k on-board ram, user code data area, ; start main program at $7000 main: bsr init ; branch to init subroutine to initialize atd bsr convert ; branch to convert subroutine for conversion done: bra done ; branch to self, convenient place for breakpoint ; ---------------------------------------------- ; subroutine init: initialize atd ; ; ---------------------------------------------- init: ldaa #$80 ; allow atd to function normally, staa atdctl2 ; atd flags clear normally & disable interrupts bsr delay ; delay (100 us) for wait delay time. ldaa #$00 ; select continue conversion in bgnd mode staa atdctl3 ; ignore freeze in atdctl3 ldaa #$01 ; select final sample time = 2 a/d clocks staa atdctl4 ; prescaler = div by 4 (prs4:0 = 1) rts ; return from subroutine
analog-to-digital converter (atd) data sheet m68hc12b family ? rev. 9.0 314 analog-to-digital converter (atd) motorola ; ---------------------------------------------- ; subroutine convert: ; ; ---------------------------------------------- ; set-up atd, make single conversion and store the result to a memory location. ; configure and start a/d conversion ; analog input signal: on port ad6 ; convert: using single channel, non-continuous ; the result will be located in adr2h convert: ldaa #$06 ; initializes atd scan=0,mult=0, pad6, ; ; write clears flag staa atdctl5 ; 4 conversions on a single conversion ; ; sequence, wtconv: brclr atdstath,#$80,wtconv ; wait for sequence complete flag ldd adr2h ; loads conversion result(adr2h) ; ; into accumulator bra convert ; continuously updates results rts ; return from subroutine ;* ------------------------------- ;* subroutine delay 100 us * ;* ------------------------------- ; delay required for atd converter to stabilize (100 usec) ldaa #$c8 ; load accumulator with "100 usec delay value" delay: deca ; decrement acc bne delay ; branch if not equal to zero rts ; return from subroutine end ; end of program
m68hc12b family ? rev. 9.0 data sheet motorola development support 315 data sheet ? m68hc12b family section 18. development support 18.1 introduction development support involves complex interactions between mcu resources and external development systems. this se ction concerns instruction queue and queue tracking signals, background debug mode, breakpoints, and instruction tagging. 18.2 instruction queue it is possible to monitor cpu activity on a cycle-by-cycle basis for debugging.the cpu12 instruction queue provides at least three bytes of program information to the cpu when instruction execution begins. the cpu12 always completely finishes executing an instruction before beg inning to execute the next instruction. status signals ipipe1 and ipipe0 provide information about data movement in the queue and indicate when the cpu begins to execute instructions. information available on the ipipe1 and ipipe0 pins is time multiplexed. external circuitry can latch data movement information on rising edges of the e-clock signal; execution start information can be latched on falling edges. table 18-1 shows the meaning of data on the pins. table 18-1. ipipe decoding data movement ? ipipe[1:0] captur ed at rising edge of e clock (1) 1. refers to data that was on the bus at the previous e falling edge. ipipe[1:0] mnemonic meaning 0:0 ? no movement 0:1 lat latch data from bus 1:0 ald advance queue and load from bus 1:1 all advance queue and load from latch execution start ? ipipe[1:0] captured at falling edge of e clock (2) 2. refers to bus cycle starti ng at this e falling edge. ipipe[1:0] mnemonic meaning 0:0 ? no start 0:1 int start interrupt sequence 1:0 sev start even instruction 1:1 sod start odd instruction
development support data sheet m68hc12b family ? rev. 9.0 316 development support motorola program information is fetched a few cycles before it is used by the cpu. to monitor cycle-by-cycle cpu ac tivity, it is necessary to externally reconstruct what is happening in the instruction queue. internally, the mcu only needs to buffer the data from program fetches. for system debug it is necessary to keep the data and its associated address in the reconstructed instruction queue. the raw signals required for reconstruction of the queue are addr, data, r/w , eclk, and status signals ipipe1 and ipipe0. the instruction queue consists of two 16-bit queue stages and a holding latch on the input of the first stage. to advance the queue means to move the word in the first stage to the second stage and move the word from either the holding latch or the data bus input buffer into the first stage. to start even (or odd) instruction means to execute the opcode in the high-or der (or low-order) byte of the second stage of the instruction queue. 18.3 background d ebug mode (bdm) background debug mode (bdm) is used for sys tem development, in-circuit testing, field testing, and programming. bdm is implemented in on-chip hardware and provides a full set of debug options. because bdm control logic does not reside in the cpu, bdm hardware commands can be executed while the cpu is operating normally. the control logic generally uses cpu dead cycles to execute these co mmands, but can steal cycles from the cpu when necessary. other bdm commands are firmware based and require the cpu to be in active background mode for ex ecution. while bdm is active, the cpu executes a firmware program located in a small on-chip rom that is available in the standard 64-kbyte memory map only while bdm is active. the bdm control logic communicates serially with an external host development system, via the bkgd pin. this single-w ire approach minimizes the number of pins needed for development support. 18.3.1 bdm serial interface the bdm serial interface requires the exte rnal controller to generate a falling edge on the bkgd pin to indicate the start of each bit time. the external controller provides this falling edge whether data is transmitted or received. bkgd is a pseudo-open-drain pin that can be driven either by an ex ternal controller or by the mcu. data is transferred msb fi rst at 16 e-clock cycles per bit (nominal speed). the interface times out if 512 e-cl ock cycles occur between falling edges from the host. the hardware clears the command register when this timeout occurs.
development support background debug mode (bdm) m68hc12b family ? rev. 9.0 data sheet motorola development support 317 the bkgd pin can receive a high or low level or transmit a high or low level. figure 18-1 , figure 18-2 , and figure 18-3 show timing for each of these cases. interface timing is synchronous to mcu cl ocks but asynchronous to the external host. the internal clock signal is shown for reference in counting cycles. figure 18-1 shows an external host transmitting a logic 1 or 0 to the bkgd pin of a target m68hc12 mcu. the host is asynchronous to the target so there is a 0-to-1 cycle delay from the host-generated fallin g edge to where the target perceives the beginning of the bit time. ten target e cycles later, the target senses the bit level on the bkgd pin. typically, the host ac tively drives the pseudo-open-drain bkgd pin during host-to-target transmissions to speed up rising edges. since the target does not drive the bkgd pin during this period, there is no need to treat the line as an open-drain signal during host-to-target transmissions. figure 18-1. bdm host to target serial bit timing figure 18-2 shows the host receiving a logic 1 from the target mcu. since the host is asynchronous to the target mcu, th ere is a 0-to-1 cycle delay from the host-generated falling edge on bkgd to the perceived start of the bit time in the target mcu. the host holds the bkgd pin low long enough for the target to recognize it (at least two target e cycl es). the host must release the low drive before the target mcu drives a brief acti ve-high speed-up pulse seven cycles after the perceived start of the bit time. the host should sample the bit level about 10 cycles after it started the bit time. earliest start of next bit target senses bit 10 cycles synchronization uncertainty e clock target mcu host transmit 1 host transmit 0 perceived start of bit time
development support data sheet m68hc12b family ? rev. 9.0 318 development support motorola figure 18-2. bdm target to host serial bit timing (logic 1) figure 18-3 shows the host receiving a logic 0 from the target mcu. since the host is asynchronous to the target mcu, th ere is a 0-to-1 cycle delay from the host-generated falling edge on bkgd to the st art of the bit time as perceived by the target mcu. the host initiates the bit time but the target mcu finishes it. since the target wants the host to receive a logic 0, it drives the bkgd pin low for 13 e-clock cycles, then briefly drives it high to s peed up the rising edge. the host samples the bit level about 10 cycles after starting the bit time. figure 18-3. bdm target to host serial bit timing (logic 0) high impedance high impedance high impedance earliest start of next bit r-c rise 10 cycles 10 cycles host samples bkgd pin perceived start of bit time bkgd pin e clock target mcu host drive to bkgd pin target mcu speedup pulse earliest start of next bit e clock target mcu host drive to bkgd pin bkgd pin perceived start of bit time 10 cycles 10 cycles host samples bkgd pin target mcu drive and speedup pulse speedup pulse high impedance
development support background debug mode (bdm) m68hc12b family ? rev. 9.0 data sheet motorola development support 319 18.3.2 enabling bdm firmware commands bdm is available in all oper ating modes, but must be made active before firmware commands can be executed. bdm is enabled by setting the enbdm bit in the bdm status register via the single-wire interface (using a hardware command; write_bd_byte at $ff01). bdm must then be activated to map bdm registers and rom to addresses $ff00 to $ffff and to put the mcu in active background mode. after the firmware is enabled, bdm can be activated by the hardware background command, by the bdm taggi ng mechanism, or by the cpu bgnd instruction. an attempt to activate bdm before firmware has been enabled causes the mcu to resume normal instruction execution after a brief delay. bdm becomes active at the next instru ction boundary following execution of the bdm background command, but tags activate bdm before a tagged instruction is executed. in special single-chip mode, backgro und operation is enabled and active immediately out of reset. this active ca se replaces the m68hc11 boot function and allows programming a syst em with blank memory. while bdm is active, a set of bdm contro l registers is mapped to addresses $ff00 to $ff06. the bdm control logic uses these registers which can be read anytime by bdm logic, not user programs. refer to 18.3.4 bdm registers for detailed descriptions. some on-chip peripherals have a bdm c ontrol bit which allows suspending the peripheral function during bdm. for exampl e, if the timer control is enabled, the timer counter is stopped while in bdm. once normal program flow is continued, the timer counter is re-enabled to simulate real-time operations. 18.3.3 bdm commands all bdm command opcodes are eight bits long and can be followed by an address and/or data, as indicated by the instru ction. these commands do not require the cpu to be in active bdm for execution. the host controller must wait 150 cycles for a non-intrusive bdm command to execute before another command can be sent. this delay includes 128 cycles for the maximum delay for a dead cycle. for data read commands, the host must insert this delay between sending the address and attempting to read the data. bdm logic retains control of the internal buses until a read or write is completed. if an operation can be completed in a single cycle, it does not intrude on normal cpu operation. however, if an operation require s multiple cycles, cpu clocks are frozen until the operation is complete. the two types of bdm commands are:  hardware  firmware
development support data sheet m68hc12b family ? rev. 9.0 320 development support motorola hardware commands allow target system memory to be read or written. target system memory includes all memory that is accessible by the cpu12 including on-chip ram, eeprom, on-chip i/o and co ntrol registers, and external memory connected to the target hc12 mcu. hardware commands are implemented in hardware logic and do not require the hc12 mcu to be in bdm mode for execution. the control logic watches the cpu12 buses to find a free bus cycle to execute the command so that the background access does not disturb the running application programs. if a free cycle is not found wi thin 128 e-clock cycles, the cpu12 is momentarily frozen so the control logic can steal a cycle. refer to table 18-2 for commands implemented in bdm control logic. table 18-2. bdm hardware commands command opcode (hex) data description background 90 none enter background mode (if firmware enabled). read_bd_byte e4 16-bit address 16-bit data out read from memory with bdm in map (may steal cycles if external access) data for odd address on low byte, data for even address on high byte. status (1) e4 ff01, 0000 0000 (out) read_bd_byte $ff01. r unning user code. (bgnd instruction is not allowed.) ff01, 1000 0000 (out) read_bd_byte $ff01. bgnd instruction is allowed. ff01, 1100 0000 (out) read_bd_byte $ff01. background mode active (waiting for single wire serial command). read_bd_word ec 16-bit address 16-bit data out read from memory with bdm in map (may steal cycles if external access) must be aligned access. read_byte e0 16-bit address 16-bit data out read from memory with bdm out of map (may steal cycles if external access) data for odd address on low byte, data for even address on high byte. read_word e8 16-bit address 16-bit data out read from memory with bdm out of map (may steal cycles if external access) must be aligned access. write_bd_byte c4 16-bit address 16-bit data in write to memory with bdm in ma p (may steal cycles if external access) data for odd address on low byte, data for even address on high byte. enable_ firmware (2) c4 ff01, 1xxx xxxx (in) write byte $ff01, set the enbdm bit. this allows execution of commands which are implemented in firmware. typically, read status, or in the msb, write the result back to status. write_bd_word cc 16-bit address 16-bit data in write to memory with bdm in ma p (may steal cycles if external access) must be aligned access. write_byte c0 16-bit address 16-bit data in write to memory with bdm ou t of map (may steal cycles if external access) data for odd address on low byte, data for even address on high byte. write_word c8 16-bit address 16-bit data in write to memory with bdm ou t of map (may steal cycles if external access) must be aligned access. 1. status command is a specific case of the read_bd_byte command. 2. enable_firmware is a specific case of the write_bd_byte command.
development support background debug mode (bdm) m68hc12b family ? rev. 9.0 data sheet motorola development support 321 the second type of bdm commands are ca lled firmware commands because they are implemented in a small rom within the hc12 mcu. the cpu must be in background mode to execute firmware commands. the usual way to get to background mode is by the hardware command background. the bdm rom is located at $ff20 to $ffff while bdm is active. there are also seven bytes of bdm registers which are located at $ff00 to $ff06 while bdm is active. the cpu executes code from this rom to perfo rm the requested operation. the bdm firmware watches for serial commands and executes them as they are received. the firmware commands are shown in table 18-3 . each of the hardware and firmware bdm commands starts with an 8-bit command code (opcode). depending upon the commands, a 16-bit address and/or a 16-bit data word is required as indicated in the tables by the command. all the read commands output 16 bits of data despite t he byte/word implication in the command name. the external host should wait 150 e-clock cycles for a non-intrusive bdm command to execute before another command is sent. this delay includes 128 e-clock cycles for the maximum delay for a free cycle. for data read commands, the host must insert this delay between sending the address and attempting to read the data. in the case of a write command, the host must delay after the data portion, before sending a new command, to be sure the write has finished. table 18-3. bdm firmware commands command opcode (hex) data description read_next 62 16-bit data out x = x + 2; read next word pointed to by x read_pc 63 16-bit data out read program counter read_d 64 16-bit data out read d accumulator read_x 65 16-bit data out read x index register read_y 66 16-bit data out read y index register read_sp 67 16-bit data out read stack pointer write_next 42 16-bit data in x = x + 2; write next word pointed to by x write_pc 43 16-bit data in write program counter write_d 44 16-bit data in write d accumulator write_x 45 16-bit data in write x index register write_y 46 16-bit data in write y index register write_sp 47 16-bit data in write stack pointer go 08 none go to user program trace1 10 none execute one user instruction then return to bdm tag g o 1 8 n o n e enable tagging and go to user program
development support data sheet m68hc12b family ? rev. 9.0 322 development support motorola the external host should delay about 32 ta rget e-clock cycles between a firmware read command and the data portion of these commands. this allows the bdm firmware to execute the instructions needed to get the requested data into the bdm shifter register. the external host should delay about 32 tar get e-clock cycles after the data portion of firmware write commands to allow bdm firmware to complete the requested write operation before a new serial command disturbs the bdm shifter register. the external host should delay about 64 target e-clock cycles after a trace1 or go command before starting any new se rial command. this delay is needed because the bdm shifter register is used as a temporary data holding register during the exit sequence to user code. bdm logic retains control of the internal buses until a read or write is completed. if an operation can be completed in a singl e cycle, it does not intrude on normal cpu12 operation. however, if an operation require s multiple cycles, cpu12 clocks are frozen until the operation is complete. 18.3.4 bdm registers seven bdm registers are mapped into the standard 64-kbyte address space when bdm is active. mapping is shown in table 18-4 . the content of the instruction register is determined by the type of background command being executed. the status register indicates bdm operating conditions. the shift register contains data being re ceived or transmitted via the serial interface. the address register is temporary storage for bdm commands. the ccr holding register preserves the content of the cpu12 condition code register while bdm is active. the only registers of interest to users are the status register and the ccr holding register. the other bdm registers are used only by the bdm firmware to execute commands. the registers are accessed by means of the hardware read_bd and write_bd commands, but should not be wr itten during bdm operation (except the ccrsav register which could be wr itten to modify the ccr value). the instruction register is written by the bdm hardware as a result of serial data shifted in on the bkgd pin. it is readable and writable in special peripheral mode table 18-4. bdm registers address register mnemonic $ff00 bdm instruction register instruction $ff01 bdm status register status $ff02?$ff03 bdm shift register shifter $ff04?$ff05 bdm address register address $ff06 bdm ccr holding register ccrsav
development support background debug mode (bdm) m68hc12b family ? rev. 9.0 data sheet motorola development support 323 on the parallel bus. it is discussed here for two conditions: when a hardware command is executed and when a firmware command is executed. the instruction register can be read or written in all modes. the hardware clears the instruction register if 512 e-clock c ycles occur between falling edges from the host. 18.3.5 bdm instruction register this section describes the bdm instruction register under hardware command and firmware command. 18.3.5.1 hardware command the bits in the bdm instruction register have the following meanings when a hardware command is executed. h/f ? hardware/firmware flag 0 = firmware instruction 1 = hardware instruction data ? data flag 0 = no data 1 = data included in command r/w ? read/write flag 0 = write 1 = read bkgnd ? hardware request to enter active background mode 0 = not a hardware background command 1 = hardware background command (instruction = $90) w/b ? word/byte tansfer flag 0 = byte transfer 1 = word transfer bd/u ? bdm map/user map flag indicates whether bdm registers and rom are mapped to addresses $ff00 to $ffff in the standard 64-kbyte address space. used only by hardware read/write commands. 0 = bdm resources not in map 1 = bdm resources in map address: $ff00 bit 7654321bit 0 read: h/f data r/w bkgnd w/b bd/u 0 0 write: reset:00000000 figure 18-4. bdm instruction register (instruction)
development support data sheet m68hc12b family ? rev. 9.0 324 development support motorola 18.3.5.2 firmware command the bits in the bdm instruction register have these meanings when a firmware command is executed. h/f ? hardware/firmware flag 0 = firmware control logic 1 = hardware control logic data ? data flag 0 = no data 1 = data included in command r/w ? read/write flag 0 = write 1 = read ttago ? trace, tag, go field regn ? register/next field indicates which register is being affected by a command. in the case of a read_next or write_next command, index register x is pre-incremented by two and the word pointed to by x is then read or written. address: $ff00 bit 7654321bit 0 read: h/f data r/w ttago regn write: reset:00000000 figure 18-5. bdm instruction register (instruction) table 18-5. ttago decoding ttago value instruction 00 ? 01 go 10 trace1 11 taggo table 18-6. regn decoding ttago value instruction 000 ? 001 ? 010 read/write next 011 pc
development support background debug mode (bdm) m68hc12b family ? rev. 9.0 data sheet motorola development support 325 18.3.6 bdm status register this register can be read or written by bdm commands or firmware. enbdm ? enable bdm bit (permit active background debug mode) 0 = bdm cannot be made active (hardware commands still allowed). 1 = bdm can be made active to allow firmware commands. bdmact ? background mode active status bit 0 = bdm not active 1 = bdm active and waiting for serial commands entag ? instruction tagging enable bit set by the taggo instruction and cleared when bdm is entered. 0 = tagging not enabled, or bdm active 1 = tagging active (bdm cannot proce ss serial commands while tagging is active.) sdv ? shifter data valid bit shows that valid data is in the serial interface shift register. used by firmware-based instructions. 0 = no valid data 1 = valid data trace asserted by the trace1 instruction address: $ff01 bit 7654321bit 0 read: enbdm edmact entag sdv trace 0 0 0 write: reset:00000000 single-chip peripheral:10000000 figure 18-6. bdm status register (status)
development support data sheet m68hc12b family ? rev. 9.0 326 development support motorola 18.3.7 bdm shifter register the 16-bit shifter register contains da ta being received or transmitted via the serial interface. it is also used by the bdm firmware for temporary storage. the register can be read or written in all modes but is not normally accessed by users. 18.3.8 bdm address register the 16-bit address register is tem porary storage for bdm hardware and firmware commands. the register can be read in all modes but is not normally accessed by users. it is written only by bdm hardware. address: $ff02 bit 7654321bit 0 read: s15 s14 s13 s12 s11 s10 s9 s8 write: reset:00000000 address: $ff03 bit 7654321bit 0 read: s7 s6 s5 s4 s3 s2 s1 s0 write: reset:00000000 figure 18-7. bdm shifter register (shifter) address: $ff04 bit 7654321bit 0 read: a15 a14 a13 a12 a11 a10 a9 a8 write: reset:00000000 address: $ff05 bit 7654321bit 0 read: a7 a6 a5 a4 a3 a2 a1 a0 write: reset:00000000 figure 18-8. bdm address register (address)
development support breakpoints m68hc12b family ? rev. 9.0 data sheet motorola development support 327 18.3.9 bdm ccr holding register the ccrsav register is used to save th e state of the condition code register (ccr) of the user?s program when entering bdm. it is also used for temporary storage in the bdm firmware. the register is initialized by the firmware to equal the cpu ccr register. 18.4 breakpoints hardware breakpoints are used to debug software on the mcu by comparing actual address and data values to predetermined data in setup registers. a successful comparison places the cpu in background debug mode (bdm) or initiates a software interrupt (swi). breakpoint features designed into the mcu include:  mode selection for bdm or swi generation  program fetch tagging for cycle of execution breakpoint  second address compare in dual address modes  range compare by disable of low byte address  data compare in full feature mode for non-tagged breakpoint  byte masking for high/low byte data compares r/w compare for non-tagged compares  tag inhibit on bdm trace 18.4.1 breakpoint modes three modes of operation determine the type of breakpoint in effect. 1. dual address-only breakpoints, each of which causes a software interrupt (swi) 2. single full-feature breakpoint which causes the part to enter background debug mode (bdm) 3. dual address-only breakpoints, each of which causes the part to enter bdm breakpoints do not occur when bdm is active. address: $ff06 bit 7654321bit 0 read: ccr7 ccr6 ccr5 ccr4 ccr3 ccr2 ccr1 ccr0 write: reset:00000000 figure 18-9. bdm ccr holding register (ccrsav)
development support data sheet m68hc12b family ? rev. 9.0 328 development support motorola 18.4.1.1 swi dual address mode in this mode, dual address-only breakpoints can be set, each of which causes a software interrupt. this is the only break point mode which can force the cpu to execute an swi. program fetch tagging is the default in this mode; data breakpoints are not possible. in dual mode each address breakpoint is affected by the respective bkale bit. the bkxrw, bkxrwe, bkmbh, and bkmbl bits are ignored. in dual address mode, the bkdbe becomes an enable for the second address breakpoint. 18.4.1.2 bdm full breakpoint mode this is a single full-featured breakpoint which causes the part to enter background debug mode. bk1ale, bk1rw, and bk1rwe have no meaning in full breakpoint mode. bkdbe enables data compare but has no meaning if bkpm = 1. bkmbh and bkmbl allow masking of high and low byte compares but has no meaning if bkpm = 1. bk0ale enables compare of low address byte.  breakpoints are not allowed if the bd m mode is already active. active mode means the cpu is executing out of the bdm rom.  bdm should not be entered from a breakpoint unless the enable bit is set in the bdm. this is important because even if the enable bit in the bdm is negated, the cpu actually does execute the bdm rom code. it checks the enable and returns if not set. if the bdm is not serviced by the monitor, then the breakpoint would be re-asserted when the bdm returns to normal cpu flow. there is no hardware to enforce restriction of breakpoint operation if the bdm is not enabled. 18.4.1.3 bdm dual address mode this mode has dual address-only breakpoin ts, each of which causes the part to enter background debug mode. in dual mode, each address breakpoint is affected by the bkpm bit, the bkxale bits, and the bkxrw and bkxrwe bits. in dual address mode, the bkdbe becomes an enab le for the second address breakpoint. the bkmbh and bkmbl bits have no effect when in a dual address mode. bdm may be entered by a breakpoint only if an internal signal from the bdm indicates background debug mode is enabled. if bkpm = 1, then bkxrw, bkxrwe, bkmbh, and bkmbl have no meaning.  breakpoints are not allowed if the bdm is already ac tive. active mode means the cpu is executing out of the bdm rom.  bdm should not be entered from a breakpoint unless the enable bit is set in the bdm. this is important because even if the enable bit in the bdm is negated, the cpu actually does execute the bdm rom code. it checks the enable and returns if not set. if the bdm is not serviced by the monitor, then the breakpoint would be re-asserted when the bdm returns to normal cpu flow. there is no hardware to enforce restriction of breakpoint operation if the bdm is not enabled.
development support breakpoints m68hc12b family ? rev. 9.0 data sheet motorola development support 329 18.4.2 breakpoint registers breakpoint operation consists of com paring data in the breakpoint address registers (brkah/brkal) to the address bus and comparing data in the breakpoint data registers (brkdh/brkdl) to the data bus. the breakpoint data registers also can be compared to the address bus. the scope of comparison can be expanded by ignoring the least significant byte of address or data matches. the scope of comparison can be limited to program data only by setting the bkpm bit in breakpoint control register 0. to trace program flow, setting the bk pm bit causes address comparison of program data only. control bits are also available that allow checking read/write matches. 18.4.2.1 breakpoint control register 0 read and write anytime. this register is used to control the breakpoint logic. bken1 and bken0 ? breakpoint mode enable bits see table 18-7 . bkpm ? break on program addresses this bit controls whether the breakpoint causes an immediate data breakpoint (next instruction boundary) or a delayed program breakpoint related to an executable opcode. data and unexecuted opcodes cannot cause a break if this address: $0020 bit 7654321bit 0 read: bken1 bken0 bkpm 0 bk1ale bk0ale 0 0 write: reset:00000000 figure 18-10. breakpoint control register 0 (brkct0) table 18-7. breakpoint mode control bken1 bken0 mode selected brkah/l usage brkdh/l usage r/w range 0 0 breakpoints off ? ? ? ? 01 swi ? dual address mode address match address match no yes 10 bdm ? full breakpoint mode address match data match ye s ye s 11 bdm ? dual address mode address match address match ye s ye s
development support data sheet m68hc12b family ? rev. 9.0 330 development support motorola bit is set. this bit has no meaning in swi dual address mode. the swi mode only performs program breakpoints. 0 = on match, break at the next instruction boundary 1 = on match, break if the match is an instruction to be executed. this uses tagging as its breakpoint mechanism. bk1ale ? breakpoint 1 range control bit only valid in dual address mode 0 = brkdl is not used to compare to the address bus. 1 = brkdl is used to compare to the address bus. bk0ale ? breakpoint 0 range control bit valid in all modes 0 = brkal is not used to compare to the address bus. 1 = brkal is used to compare to the address bus. 18.4.2.2 breakpoint control register 1 this register is read/write in all modes. bkdbe ? enable data bus bit enables comparing of address or data bus values using the brkdh/l registers. 0 = brkdh/l registers are not used in any comparison. 1 = brkdh/l registers are used to compare address or data (depending upon the mode selecti ons bken1 and bken0). bkmbh ? breakpoint mask high bit disables the comparing of the high byte of data when in full breakpoint mode. used in conjunction with the bkdbe bit (which should be set) 0 = high byte of data bus (bits 15:8) are compared to brkdh. 1 = high byte is not used in comparisons. table 18-8. breakpoint address range control bk1ale bk0ale address range selected ? 0 upper 8-bit address only for full mode or dual mode bkp0 ? 1 full 16-bit address for full mode or dual mode bkp0 0 ? upper 8-bit address only for dual mode bkp1 1 ? full 16-bit address for dual mode bkp1 address: $0021 bit 7654321bit 0 read: 0 bkdbe bkmbh bkmbl bk1rwe bk1rw bk0rwe bk0rw write: reset:00000000 figure 18-11. breakpoint control register 1 (brkct1)
development support breakpoints m68hc12b family ? rev. 9.0 data sheet motorola development support 331 bkmbl ? breakpoint mask low bit disables the matching of the low byte of data when in full breakpoint mode. used in conjunction with the bkdbe bit (which should be set) 0 = low byte of data bus (bits 7?0) are compared to brkdl. 1 = low byte is not used to in comparisons. bk1rwe ? r/w compare enable bit enables the comparison of the r/w signal to further specify what causes a match. this bit is not useful in program breakpoints or in full breakpoint mode. this bit is used in conjunction with a second address in dual address mode when bkdbe = 1. 0 = r/w is not used in comparisons. 1 = r/w is used in comparisons. bk1rw ? r/w compare value bit when bk1rwe = 1, this bit determines the type of bus cycle to match. 0 = a write cycle is matched. 1 = a read cycle is matched. bk0rwe ? r/w compare enable bit enables the comparison of the r/w signal to further specify what causes a match. this bit is not useful in program breakpoints. 0 = r/w is not used in the comparisons. 1 = r/w is used in comparisons. bk0rw ? r/w compare value bit when bk0rwe = 1, this bit determines the type of bus cycle to match. 0 = write cycle is matched. 1 = read cycle is matched. table 18-9. breakpoint read/write control bk1rwe bk1rw bk0rwe bk0rw read/write selected ?? 0 xr/w is don?t care for full mode or dual mode bkp0 ?? 1 0r/w is write for full mode or dual mode bkp0 ?? 1 1r/w is read for full m ode or dual mode bkp0 0x??r/w is don?t care for dual mode bkp1 10??r/w is write for dual mode bkp1 11??r/w is read for dual mode bkp1
development support data sheet m68hc12b family ? rev. 9.0 332 development support motorola 18.4.2.3 breakpoint address register high these bits are used to compare against th e most significant byte of the address bus. 18.4.2.4 breakpoint address register low these bits are used to compare against th e least significant byte of the address bus. these bits may be excluded from being used in the match if bk0ale = 0. 18.4.2.5 breakpoint data register high these bits are compared to the most significant byte of the data bus in full breakpoint mode or the most significant byte of the address bus in dual address modes. bke1, bke0, bkdbe, and bkmbh cont rol how this byte is used in the breakpoint comparison. address: $0022 bit 7654321bit 0 read: bit 15 14 13 12 11 10 9 bit 8 write: power on reset:00000000 figure 18-12. breakpoint address register high (brkah) address: $0023 bit 7654321bit 0 read: bit 7654321bit 0 write: power on reset:00000000 figure 18-13. breakpoint address register low (brkal) address: $0024 bit 7654321bit 0 read: bit 15 14 13 12 11 10 9 bit 8 write: power on reset:00000000 figure 18-14. breakpoint data register high (brkdh)
development support instruction tagging m68hc12b family ? rev. 9.0 data sheet motorola development support 333 18.4.2.6 breakpoint data register low byte these bits are compared to the least signi ficant byte of the data bus in full breakpoint mode or the least significant byte of the address bus in dual address modes. bken1, bken0, bkdbe, bk1ale, and bkmbl control how this byte is used in the breakpoint comparison. note: after a power-on reset, registers brkah, brkal, brkdh, and brkdl are cleared but these registers are not affected by normal resets. 18.5 instruction tagging the instruction queue and cycle-by-cycle cp u activity can be reconstructed in real time or from trace history that was c aptured by a logic analyzer. however, the reconstructed queue cannot be used to stop the cpu at a specific instruction, because execution has already begun by t he time an operation is visible outside the mcu. a separate instruction tagging mechanism is provided for this purpose. executing the bdm taggo command configures two mcu pins for tagging. tagging information is latched on the fa lling edge of eclk along with program information as it is fetched. tagging is allowed in all modes. tagging is disabled when bdm becomes active and bdm seri al commands cannot be processed while tagging is active. taghi is a shared function of the bkgd pin. taglo is a shared function of the pe3/lstrb pin, a multiplexed i/o pin. for 1/4 cycle before and after the rising edge of the e clock, this pin is the lstrb driven output. taglo and taghi inputs are captured at the falling edge of the e clock. a logic 0 on taghi and/or taglo marks (tags) the instruction on the high and/or low byte of the program word that was on the data bus at the same falling edge of the e clock. table 18-10 shows the functions of the two tagging pins. the pins operate independently; the state of one pin does not affect the function of the other. the presence of logic level 0 on either pin at the fall of eclk performs the indicated function. tagging is allowed in all modes. tagging is disabled when bdm becomes active and bdm serial commands are not processed while tagging is active. address: $0025 bit 7654321bit 0 read: bit 7654321bit 0 write: power on reset:00000000 figure 18-15. breakpoint data register low (brkdl)
development support data sheet m68hc12b family ? rev. 9.0 334 development support motorola the tag follows the information in the queue as the queue is advanced. when a tagged instruction reaches the head of the queue, the cpu enters active background debug mode rather than executing the instruction. this is the mechanism by which a development sy stem initiates hardware breakpoints. currently, the tool configuration shown in figure 18-16 is used. figure 18-16. bdm tool connector table 18-10. tag pin function taghi taglo tag 1 1 no tag 10 low byte 0 1 high byte 0 0 both bytes 2 4 6 5 3 1 reset bkgd v dd gnd v fp nc
m68hc12b family ? rev. 9.0 data sheet motorola electrical specifications 335 data sheet ? m68hc12b family section 19. electrical specifications 19.1 introduction this section contains electric al and timing specifications. 19.2 maximum ratings maximum ratings are the extreme limits to which the mcu can be exposed without permanently damaging it. note: this device is not guaranteed to operate properly at the maximum ratings. refer to 19.5 5.0 volt dc electrical characteristics for guaranteed operating conditions. note: this device contains circuitry to pr otect the inputs against damage due to high static voltages or electric fields; however , it is advised that normal precautions be taken to avoid application of any volta ge higher than maximum-rated voltages to this high-impedance circuit. for proper operation, it is recommended that v in and v out be constrained to the range v ss rating symbol value unit supply voltage v dd , v dda , v ddx ?0.3 to +6.5 v input voltage v in ?0.3 to +6.5 v maximum current per pin excluding v dd and v ss i in 25 ma storage temperature t stg ?55 to +150 c v dd differential voltage v dd ?v ddx 6.5 v
electrical specifications data sheet m68hc12b family ? rev. 9.0 336 electrical specifications motorola 19.3 functional o perating range 19.4 thermal characteristics rating symbol value unit all devices in this document meet these operating temperature ranges: ?c? temperature range ?v? temperature range ?m? temperature range t a t l to t h ? 40 to + 85 ? 40 to + 105 ? 40 to + 125 c operating voltage range v dd 5.0 10% v characteristic symbol value unit average junction temperature t j t a + (p d ja ) c ambient temperature t a user-determined c package thermal resistance (junction-to-ambient) 80-pin quad flat pack (qfp) ja 76 c/w total power dissipation (1) 1. this is an approximate value, neglecting p i/o . p d p int + p i/o or w device internal power dissipation p int i dd v dd w i/o pin power dissipation (2) 2. for most applications, p i/o ? p int and can be neglected. p i/o user-determined w a constant (3) 3. k is a constant pertaining to th e device. solve for k with a known t a and a measured p d (at equilibrium). use this value of k to solve for p d and t j iteratively for any value of t a . k p d (t a + 273 c) + ja p d 2 w/ c k t j 273 c + -------------------------- -
electrical specifications 5.0 volt dc electrical characteristics m68hc12b family ? rev. 9.0 data sheet motorola electrical specifications 337 19.5 5.0 volt dc elect rical characteristics characteristic (1) symbol min max unit input high voltage, all inputs v ih 0.7 v dd v dd + 0.3 v input low voltage, all inputs v il v ss ? 0.3 0.2 v dd v output high voltage, all i/o and output pins except xtal normal drive strength i oh = ? 10.0 a i oh = ? 0.8 ma reduced drive strength i oh = ? 4.0 a i oh = ? 0.3 ma v oh v dd ? 0.2 v dd ? 0.8 v dd ? 0.2 v dd ? 0.8 ? ? ? ? v output low voltage, all i/o and output pins except xtal normal drive strength i ol = 10.0 a i ol = 1.6 ma reduced drive strength i ol = 3.6 a i ol = 0.6 ma v ol ? ? ? ? v ss + 0.2 v ss + 0.4 v ss + 0.2 v ss + 0.4 v input leakage current (2) v in = v dd or v ss all input-only pins except atd (3) and v fp i in ? 5 a three-state leakage, i/o ports, bkgd, and reset i oz ? 2.5 a input capacitance all input pins and atd pins (non-sampling) atd pins (sampling) all i/o pins c in ? ? ? 10 15 20 pf output load capacitance all outputs except ps7?ps4 ps7?ps4 when configured as spi c l ? ? 90 200 pf programmable active pullup current xirq , dbe , lstrb , r/w , ports a, b, dlc, p, s, t moda, modb active pulldown during reset bkgd passive pullup i apu 50 50 50 500 500 500 a 1. v dd = 5.0 vdc 10%, v ss = 0 vdc, t a = t l to t h , unless otherwise noted 2. specification is for parts in the ?40 to +85 c range. higher temperature ranges will result in increased current leakage. 3. see 19.8 atd dc electrical characteristics .
electrical specifications data sheet m68hc12b family ? rev. 9.0 338 electrical specifications motorola 19.6 supply current characteristic (1) symbol 2 mhz4 mhz8 mhz unit maximum total supply current run: single-chip mode expanded mode i dd 15 25 25 45 45 70 ma ma wait: (all peripheral functions shut down) single-chip mode expanded mode w idd 1.5 4 3 7 5 10 ma ma stop: single-chip mode, no clocks ? 40 to + 85 + 85 to + 105 + 105 to + 125 s idd 10 25 50 10 25 50 10 25 50 a a a maximum power dissipation (2) single-chip mode expanded mode p d 75 125 125 225 225 350 mw 1. v dd = 5.0 vdc 10%, v ss = 0 vdc, t a = t l to t h , unless otherwise noted 2. includes i dd and i dda
electrical specifications atd maximum ratings m68hc12b family ? rev. 9.0 data sheet motorola electrical specifications 339 19.7 atd maximum ratings 19.8 atd dc electri cal characteristics characteristic symbol value units atd reference voltage v rh v dda v rl v ssa v rh v rl ? 0.3 to + 6.5 ? 0.3 to + 6.5 v v ss differential voltage | v ss ? v ssa | 0.1 v v dd differential voltage v dd ? v dda v dda ? v dd 6.5 0.3 v v ref differential voltage | v rh ? v rl | 6.5 v reference to supply differential voltage | v rh ? v dda | 6.5 v characteristic (1) symbol min max unit analog supply voltage v dda 4.5 5.5 v analog supply current, normal operation i dda ?1.0ma reference voltage, low v rl v ssa v dda / 2 v reference voltage, high v rh v dda / 2v dda v v ref differential reference voltage (2) v rh ? v rl 4.5 5.5 v input voltage (3) v indc v ssa v dda v input current, off channel (4) i off ? 100 na reference supply current i ref ? 250 a input capacitancenot sampling sampling c inn c ins ? ? 10 15 pf 1. v dd = 5.0 vdc 10%, v ss = 0 vdc, t a = t l to t h , atd clock = 2 mhz, unless otherwise noted 2. accuracy is guaranteed at v rh ? v rl = 5.0 v 10%. 3. to obtain full-scale, full-range results, v ssa v rl v indc v rh v dda . 4. maximum leakage occurs at maximum operating temperature. cu rrent decreases by approximately one-half for each 10 c decrease from maximum temperature.
electrical specifications data sheet m68hc12b family ? rev. 9.0 340 electrical specifications motorola 19.9 analog converter o perating characteristics characteristic (1) symbol min typ max unit 8-bit resolution (2) 1 count ? 20 ? mv 8-bit differential non-linearity (3) dnl ? 0.5 ? + 0.5 count 8-bit integral non-linearity (3) inl ? 1? + 1 count 8-bit absolute error (3), (4) 2, 4, 8, and 16 atd sample clocks ae ? 1? + 1 count 10-bit resolution (2) 1 count ? 5 ? mv 10-bit differential non-linearity (3) dnl ?2 ? 2 count 10-bit integral non-linearity (3) inl ?2 ? 2 count 10-bit absolute error (3) 2, 4, 8, and 16 atd sample clocks ae ?2.5 ? 2.5 count maximum source impedance r s ?20 see (5) k ? 1. v dd = 5.0 vdc 10%, v ss = 0 vdc, t a = t l to t h , atd clock = 2 mhz, unless otherwise noted 2. v rh ? v rl 5.12 v; v dda ? v ssa = 5.12 v 3. at v ref = 5.12 v, one 8-bit count = 20 mv, and one 10-bit count = 5 mv. inl and dnl are characterized using the process window parameters affecting the atd accuracy, but they are not tested. 4. eight-bit absolute error of 1 count (20 mv) includes 1/2 count (10 mv) inherent quantization error and 1/2 count (10 mv) circuit (differential, integral, and offset) error. 5. maximum source impedance is application-dependent. erro r resulting from pin leakage depends on junction leakage into the pin and on leakage due to charge-sharing with internal capacitance. error from junction leakage is a function of external source impedance and input leakage current. expected error in result value due to junction leakage is expressed in voltage (v errj ): v errj = r s i off where i off is a function of operating temperature. charge-sharing e ffects with internal capacitors are a function of atd clock speed, the number of channels being scanned, and source im pedance. for 8-bit conversions, charge pump leakage is computed as: v errj = 0.25 pf v dda r s atdclk/(8 number of channels)
electrical specifications atd ac operating characteristics (operating) m68hc12b family ? rev. 9.0 data sheet motorola electrical specifications 341 19.10 atd ac operating c haracteristics (operating) 19.11 eeprom characteristics characteristic (1) symbol min max unit mcu clock frequency (p-clock) f pclk 2.0 8.0 mhz atd operating clock frequency f at d c l k 0.5 2.0 mhz atd 8-bit conversion period atd clock cycles (2) atd conversion time (3) n conv8 t conv8 18 9 32 16 cycles s atd 10-bit conversion period atd clock cycles (2) atd conversion time (3) n conv10 t conv10 20 10.0 34 17 cycles s stop and atd power-up recovery time (4) v dda = 5.0 v t sr ?10 s 1. v dd = 5.0 vdc 10%, v ss = 0 vdc, t a = t l to t h , atd clock = 2 mhz, unless otherwise noted 2. the minimum time assumes a final samp le period of 2 atd clock cycles while t he maximum time assu mes a final sample period of 16 atd clocks. 3. this assumes an atd clock frequency of 2.0 mhz. 4. from the time adpu is asserted until the time an atd conversion can begin characteristic (1) symbol min typ max unit minimum programming clock frequency (2) f prog 1.0 ? ? mhz programming time t prog 10.0 ? 10.5 ms clock recovery time, following stop, to continue programming t crstop ?? t prog + 1 ms erase time t erase 10.0 ? 10.5 ms write/erase endurance ? 10,000 ? ? cycles data retention ? 10 ? ? years 1. v dd = 5.0 vdc 10%, v ss = 0 vdc, t a = t l to t h , unless otherwise noted 2. rc oscillator must be enabled if programming is desired and f sys < f prog .
electrical specifications data sheet m68hc12b family ? rev. 9.0 342 electrical specifications motorola 19.12 flash eeprom characteristics 19.12.1 programming voltage supply envelope the key to preventing damage to the flash array or corruption of the data contained in the memory is the programming voltage envelope shown in figure 19-1 . many of the problems that cu stomers experience with flash devices are due to a failure to ensure that their voltage sources always meet these requirements. the most important single thing to remember from this diagram is that v fp and v dd should always be at the same level, ex cept during an actual program or erase cycle. corruption of flash data is often encountered when v fp is allowed to exceed v dd during the power-up and power-down phases. conversely, if v fp is allowed to fall below 0.35 volts lower than v dd at any time, damage to the flash array can occur. note: although figure 19-1 shows a lower boundary of 4.15 volts on v fp during the normal read phase, v fp always must be no more than .35 volts below v dd . for example, if the operating voltage of v dd in the system is 5.2 volts, v fp can be no lower than 4.85 volts. characteristic (1) symbol min typ max units program/erase supply voltage read only program/erase/verify v fp v dd ? 0.35 11.4 v dd 12.0 v dd + 0.5 12.6 v program/erase supply current word program (v fp = 12 v) erase (v fp = 12 v) i fp ??30 4 ma number of programming pulses n pp ? ? 50 pulses programming pulse t ppulse 20 ? 25 s program to verify time t vprog 10 ? ? s program margin p m 100 (2) ??% number of erase pulses n ep ? ? 5 pulses erase pulse t epulse 5?10ms erase to verify time t verase 1??ms erase margin e m 100 (3) ??% program/erase endurance 100 ? ? cycles data retention 10 ? ? years 1. v dd = 5.0 vdc 10%, v ss = 0 vdc, t a = t l to t h , unless otherwise noted 2. the number of margin pulses required is the same as the number of pulses used to program or erase.
electrical specifications flash eeprom characteristics m68hc12b family ? rev. 9.0 data sheet motorola electrical specifications 343 figure 19-1. programming voltage envelope 19.12.2 example v fp protection circuitry figure 19-2 shows an example of a circuit wh ich, if properly implemented, can maintain the appropriate voltage levels on the v fp pin. this section outlines the design for this circuit, what each component is intended to do, and some design considerations when designing v fp pin protection. figure 19-2. v fp supply circuit 13.5 v 12.6 v 11.4 v 5.5 v 4.5 v 4.15 v 0 v ?0.30 v v fp envelope v dd envelope combined v dd and v fp 30 ns maximum t er program erase power down power up normal read v dd c1+ c1 ? c2+ c2? 5 2 1 4 3 220 nf 220 nf 7 gnd shdn v out st662a 6 8 c4 10 f c3 1?100 nf r1 10 k ? v fp shutdown c5 10 f c6 100 nf v dd v fp i/o v ss v dd
electrical specifications data sheet m68hc12b family ? rev. 9.0 344 electrical specifications motorola the general idea of this circuit implementation is to supply v fp from a dc-dc converter. this dc-dc converter, like most, provides a shutdown feature which allows the converter?s output to be shut off. when the shdn pin on the converter is pulled high, as the 10-k ? pullup resistor (r1) does, the output v out is shorted to the v dd supply. this requires that the progra mming and erasing routines assert a port pin on the mcu to turn on the converter and supply the 12-volt programming voltage during the programming or erasing cycle. simple programming and erasing routines, such as those shown earlier in this application note, will no longer suffice. by implementing this solution, v fp is tied to v dd on power-up and power-down, ensuring that they rise and fall together. capacitors c5 and c6 are the normal decoupling capacitors on the v dd supply lines. c3 is used to reduce electromagnetic interference (emi) in the circuit. if c3 is too large, v fp will not be allowed to fall with v dd , potentially causing data corruption in the flash array. (refer to figure 19-3 .) c4 is where the dc-dc converter stores charge to supply v out to the target device. the supply must be able to source approximately 30 ma of current for at least 20 s (based on programming cycle requirements) and 4 ma of current for at least 10 ms (based on erase cycle requirements). a certain degree of experimentation might be required when selecting c4 and c3. when trying different capacitor values , always monitor the effects on v fp decay during power-down and current supplied to the v fp pin. r1 must be no larger than 10 k ? , to make certain that the shdn pin on the dc-dc converter is never allo wed to fall below v dd unless the output pin of the microcontroller is driven low. the external pullup ensures this behavior, no matter what port pin is used on the microcontroller or what the internal structure of that pin looks like. without a strong enough pullup resistor on r1, the voltage on the shdn pin might drop during a reset event, causing the dc-dc converter to activate and begin driving the voltage on v out to begin to rise to 12 vo lts. this would result in data corruption in the flash. note: figure 19-2 is different from the recommended circuit shown in information about st662a from st microelectronics, but it is correct. the change is in the location of the capacitor c4, which is now placed between v dd and v fp . this change was implemented with the cooperation of st microe lectronics to aid in tracking a rapidly falling v dd voltage level, such as in figure 19-3 and figure 19-4 . this circuit also has been verified with the maxim integrated products device (max662). be certain that v fp decays with v dd , as shown in figure 19-4 , as new capacitance values are tested. the rate of decay of the v dd supply powering down will help define how large the c3 capacitance can be made.
electrical specifications flash eeprom characteristics m68hc12b family ? rev. 9.0 data sheet motorola electrical specifications 345 figure 19-3. v fp exceeding v dd during power-down figure 19-4. v fp tracking v dd during power-down
electrical specifications data sheet m68hc12b family ? rev. 9.0 346 electrical specifications motorola when checking to ensure that the reservoir capacitance value of c4 is not too low, the voltage level of v fp can be monitored during an initial erase and a write pulse. remember that the largest current draw on erasing is when all of the bits of the flash are programmed to 0. conversely, the highest programming current is seen when programming all the bits to 0 from the erased state of 1. the user should look at this on an oscilloscope, due to the brevity of the pulses. using a port pin or the shdn signal may be useful to trigger the scope when the pulses are fired. if the voltage dips below 11.4 volts, the capacitance used can be increased, but be sure to verify that decay rates of v dd and v fp are still the same. if v fp is declining with each successive pulse, try inserti ng some delays between each pulse to allow the charge pump to recharge. the solution shown here uses the st662a dc-dc converter, but any similar device will work. some other options are t he ltc1262c from linear technology corporation or the max662 from maxim integrated products, inc. 19.13 pulse-width modu lator characteristics characteristic (1) symbol min max unit e-clock frequency f eclk ?8.0mhz a-clock frequency selectable f aclk f eclk /128 f eclk hz b-clock frequency selectable f bclk f eclk /128 f eclk hz left-aligned pwm frequency 8-bit 16-bit f lpwm f eclk /1 m f eclk /256 m f eclk /2 f eclk /2 hz left-aligned pwm resolution r lpwm f eclk /4 k f eclk hz center-aligned pwm frequency 8-bit 16-bit f cpwm f eclk /2 m f eclk /512 m f eclk f eclk hz center-aligned pwm resolution r cpwm f eclk /4 k f eclk hz 1. v dd = 5.0 vdc 10%, v ss = 0 vdc, t a = t l to t h , unless otherwise noted
electrical specifications control timing m68hc12b family ? rev. 9.0 data sheet motorola electrical specifications 347 19.14 control timing figure 19-5. timer inputs characteristic symbol 8.0 mhz unit min max frequency of operation f o dc 8.0 mhz e-clock period t cyc 125 ? ns crystal frequency f xtal ? 16.0 mhz external oscillator frequency 2 f o dc 16.0 mhz processor control setup time t pcsu = t cyc / 2 + 20 t pcsu 82 ? ns reset input pulse width (1) to guarantee external reset vector minimum input time (can be pre-empted by internal reset) pw rstl 32 2 ? ? t cyc mode programming setup time t mps 4? t cyc mode programming hold time t mph 10 ? ns interrupt pulse width, irq edge-sensitive mode pw irq = 2 t cyc + 20 pw irq 270 ? ns wait recovery startup time t wrs = 4 t cyc t wrs ?4 t cyc timer input capture pulse width pw tim = 2 t cyc + 20 pw tim 270 ? ns pulse accumulator pulse width pw pa tbd ? ns 1. reset is recognized during the first clock cycle it is held low. internal circuitry then drives the pin low for 16 clock cycles, releases the pin, and samp les the pin level eight cycl es later to determine the source of the interrupt. pt7 2 pt7 1 pt7?pt0 (2) pt7?pt0 (1) n otes: 1. rising edge sensitive input 2. falling edge sensitive input pw tim pw pa
data sheet m68hc12b family ? rev. 9.0 348 electrical specifications motorola electrical specifications figure 19-6. power-on and external reset timing diagram t pcsu internal moda, modb eclk extal v dd reset 4098 t cyc free fffe fffe 3rd 1st 2nd free fffe fffe fffe t mph pw rstl t mps address pipe pipe pipe 1st exec 3rd pipe 2nd pipe 1st pipe 1st exec note: reset timing is subject to change.
m68hc12b family ? rev. 9.0 data sheet motorola electrical specifications 349 electrical specifications control timing figure 19-7. stop recovery timing diagram pw irq t stopdelay (3) irq (1) irq (2) or xirq eclk 1st address (4) sp-9 free free vector free free resume program with instruction which follows the stop instruction. internal address (5) clocks notes: 1. edge-sensitive irq pin (irqe bit = 1) 2. level-sensitive irq pin (irqe bit = 0) 3. t stopdelay = 4098 t cyc if dly bit = 1 or 2 t cyc if dly = 0. 4. xirq with x bit in ccr = 1. 5. irq or (xirq with x bit in ccr = 0) opt 1st 2nd 3rd 1st exec pipe pipe exec sp-8 sp-6 fetch pipe sp-6 sp-8 sp-9
data sheet m68hc12b family ? rev. 9.0 350 electrical specifications motorola electrical specifications figure 19-8. wait recovery timing diagram t pcsu pc, iy, ix, b:a, ccr stack registers eclk r/w address irq , xirq , or internal interrupts sp ? 2 sp ? 4 sp ? 6 . . . sp ? 9 sp ? 9 sp ? 9 . . . sp ? 9 sp ? 9 vector free 1st 2nd 3rd pipe t wrs note: reset also causes recovery from wait. address pipe pipe 1st exec
m68hc12b family ? rev. 9.0 data sheet motorola electrical specifications 351 electrical specifications control timing figure 19-9. interrupt timing diagram t pcsu pc, iy, ix, b:a, ccr stack registers eclk r/w address irq , xirq , or internal interrupts sp ? 2 sp ? 4 sp ? 6 . . . sp ? 9 sp ? 9 sp ? 9 . . . sp ? 9 sp ? 9 vector free 1st 2nd 3rd pipe t wrs note: reset also causes recovery from wait. address pipe pipe 1st exec
electrical specifications data sheet m68hc12b family ? rev. 9.0 352 electrical specifications motorola 19.15 peripheral port timing figure 19-10. port read timing diagram figure 19-11. port write timing diagram characteristic symbol 8.0 mhz unit min max frequency of operation e-clock frequency f o dc 8.0 mhz e-clock period t cyc 125 ? ns peripheral data setup time mcu read of ports t pdsu = t cyc / 2 + 40 t pdsu 102 ? ns peripheral data hold time mcu read of ports t pdh 0?ns delay time, peripheral data write mcu write to ports t pwd ?40ns delay time, peripheral data write mcu write to port can t pwd ?71ns eclk mcu read of port ports t pdsu t pdh eclk mcu write to port previous port data new data valid port a t pwd
electrical specifications multiplexed expansion bus timing m68hc12b family ? rev. 9.0 data sheet motorola electrical specifications 353 19.16 multiplexed expansion bus timing note: use of the multiplexed expansion bus at 8 mhz is discouraged due to tad delay factors. num characteristic (1), (2), (3), (4), (5) delay symbol 8 mhz 2 mhz unit min max min max ? frequency of operation (e-clock frequency) ? f o dc 8.0 dc 8.0 mhz 1 cycle timet cyc = 1 / f o ? t cyc 125 ? 500 ? ns 2 pulse width, e lowpw el = t cyc / 2 + delay ? 4 pw el 59 ? 246 ? ns 3 pulse width, e high (6) pw eh = t cyc / 2 + delay ? 2 pw eh 59 ? 248 ? ns 5 address delay timet ad = t cyc / 4 + delay 27 t ad ? 67.5 ? 152 ns 7 address valid time to eclk riset av = pw el ? t ad ? t av ?6.2 ? 94 ? ns 8 multiplexed address hold timet mah = t cyc / 4 + delay ? 18 t mah 13 ? 107 ? ns 9 address hold to data valid ? t ahds 30 ? 20 ? ns 10 data hold to high impedancet dhz = t ad ? 20 ? t dhz ? 45.2 ? 132 ns 11 read data setup time ? t dsr 31.2 ? 25 ? ns 12 read data hold time ? t dhr 0?0?ns 13 write data delay time ? t ddw ? 62.5 ? 165 ns 14 write data hold time ? t dhw 25 ? 20 ? ns 15 write data setup time (6) t dsw = pw eh ? t ddw ? t dsw 5.8 ? 83 ? ns 16 read/write delay timet rwd = t cyc / 4 + delay 18 t rwd ? 57.5 ? 143 ns 17 read/write valid time to e riset rwv = pw el ? t rwd ? t rwv 3.8 ? 103 ? ns 18 read/write hold time ? t rwh 25 ? 20 ? ns 19 low strobe (7) delay timet lsd = t cyc / 4 + delay 18 t lsd ? 57.5 ? 143 ns 20 low strobe (7) valid time to e riset lsv = pw el ? t lsd ? t lsv 3.8 ? 103 ? ns 21 low strobe (7) hold time ? t lsh 25 ? 20 ? ns 22 address access time (6) t acca = t cyc ? t ad ? t dsr ? t acca ? 27.6 ? 323 ns 23 access time from e rise (6) t acce = pw eh ? t dsr ? t acce ? 27.8 ? 223 ns 24 dbe delay from eclk rise (6) t dbed = t cyc / 4 + delay 8 t dbed ? 57.5 ? 133 ns 25 dbe valid timet dbe = pw eh ? t dbed ? t dbe 11.8 ? 115 ? ns 26 dbe hold time from eclk fall ? t dbeh ?3 10 ?3 10 ns 1. v dd = 5.0 vdc 10%, v ss = 0 vdc, t a = t l to t h , unless otherwise noted 2. all timings are calculated for normal port drives. 3. crystal input is required to be within 45% to 55% duty. 4. reduced drive must be off to meet these timings. 5. unequalled loading of pins will affect relative timing numbers. 6. this characteristic is affected by clock stretch. add n t cyc where n = 0, 1, 2, or 3, depending on the number of clock stretches. 7. without tag enabled
electrical specifications data sheet m68hc12b family ? rev. 9.0 354 electrical specifications motorola figure 19-12. multiplexed expansion bus timing diagram dbe 24 25 eclk r/w 1 2 3 18 11 12 14 note: measurement points shown are 20% and 70% of v dd . 13 16 17 read write 23 lstrb 21 19 20 w/o tag enabled 5 7 22 8 15 address/data multiplexed address address data data 10 9 26
electrical specifications serial peripheral interface (spi) timing m68hc12b family ? rev. 9.0 data sheet motorola electrical specifications 355 19.17 serial pe ripheral interface (spi) timing num function (1) symbol min max unit operating frequency master slave f op dc dc 1 / 2 1 / 2 e-clock frequency 1 sck period master slave t sck 2 2 256 ? t cyc t cyc 2 enable lead time master slave t lead 1 / 2 1 ? ? t sck t cyc 3 enable lag time master slave t lag 1 / 2 1 ? ? t sck t cyc 4 clock (sck) high or low time master slave t wsck t cyc ? 30 t cyc ? 30 128 t cyc ? ns ns 5 sequential transfer delay master slave t td 1 / 2 1 ? ? t sck t cyc 6 data setup time (inputs) master slave t su 30 30 ? ? ns ns 7 data hold time (inputs) master slave t hi 0 30 ? ? ns ns 8 slave access time t a ?1 t cyc 9 slave miso disable time t dis ?1 t cyc 10 data valid (after sck edge) master slave t v ? ? 50 50 ns ns 11 data hold time (outputs) master slave t ho 0 0 ? ? ns ns 12 rise time input output t ri t ro ? ? t cyc ? 30 30 ns ns 13 fall time input output t fi t fo ? ? t cyc ? 30 30 ns ns 1. v dd = 5.0 vdc 10%, v ss = 0 vdc, t a = t l to t h , 200 pf load on all spi pins, ac timing is shown with respect to 20% v dd and 70% v dd levels, unless otherwise noted.
electrical specifications data sheet m68hc12b family ? rev. 9.0 356 electrical specifications motorola figure 19-13. spi master timing diagram sck output sck output miso input mosi output ss (1 ) output 1 10 6 7 msb in (2) bit 6 . . . 1 lsb in msb out (2) lsb out bit 6 . . . 1 11 4 4 2 10 cpol = 0) cpol = 1 5 3 12 13 1. ss output mode (dds7 = 1, ssoe = 1). 2. lsbf = 0. for lsbf = 1, bit order is lsb, bit 1, ..., bit 6, msb. a) spi master timing (cpha = 0) b) spi master timing (cpha = 1) sck output sck output miso input mosi output 1 6 7 msb in (2) bit 6 . . . 1 lsb in master msb out (2) master lsb out bit 6 . . . 1 4 4 10 12 13 11 port data cpol = 0 cpol = 1 port data ss (1 ) output 5 2 13 12 3 1. ss output mode (dds7 = 1, ssoe = 1). 2. lsbf = 0. for lsbf = 1, bit order is lsb, bit 1, ..., bit 6, msb. notes: notes:
electrical specifications serial peripheral interface (spi) timing m68hc12b family ? rev. 9.0 data sheet motorola electrical specifications 357 figure 19-14. spi slave timing diagram sck input sck input mosi input miso output ss input 1 10 6 7 msb in bit 6 . . . 1 lsb in msb out slave lsb out bit 6 . . . 1 11 4 4 2 8 cpol = 0 cpol = 1 5 3 13 note: not defined but normally msb of character just received slave 13 12 11 see 12 note 9 sck input sck input mosi input miso output 1 6 7 msb in bit 6 . . . 1 lsb in msb out slave lsb out bit 6 . . . 1 4 4 10 12 13 11 see cpol = 0 cpol = 1 ss input 5 2 13 12 3 note: not defined but normally lsb of character just received slave note 8 9 a) spi slave timing (cpha = 0) b) spi slave timing (cpha = 1)
electrical specifications data sheet m68hc12b family ? rev. 9.0 358 electrical specifications motorola
m68hc12b family ? rev. 9.0 data sheet motorola mechanical specifications 359 data sheet ? m68hc12b family section 20. mechanical specifications 20.1 introduction this section provides dimensions for the 80-pin quad flat pack (qfp).
mechanical specifications data sheet m68hc12b family ? rev. 9.0 360 mechanical specifications motorola 20.2 80-pin quad flat pack (case 841b-02) notes: 1. dimensioning and tolerancing per ansi y14.5m, 1982. 2. controlling dimension: millimeter. 3. datum plane -h- is located at bottom of lead and is coincident with the lead where the lead exits the plastic body at the bottom of the parting line. 4. datums -a-, -b- and -d- to be determined at datum plane -h-. 5. dimensions s and v to be determined at seating plane -c-. 6. dimensions a and b do not include mold protrusion. allowable protrusion is 0.25 per side. dimensions a and b do include mold mismatch and are determined at datum plane -h-. 7. dimension d does not include dambar protrusion. allowable dambar protrusion shall be 0.08 total in excess of the d dimension at maximum material condition. dambar cannot be located on the lower radius or the foot. section b-b 61 60 detail a l 41 40 80 -a- l -d- a s a-b m 0.20 d s h 0.05 a-b s 120 21 -b- b v j f n d view rotated 90 detail a b b p -a-,-b-,-d- e h g m m detail c seating plane -c- c datum plane 0.10 -h- u t r q k w x detail c dim min max millimeters a 13.90 14.10 b 13.90 14.10 c 2.15 2.45 d 0.22 0.38 e 2.00 2.40 f 0.22 0.33 g 0.65 bsc h --- 0.25 j 0.13 0.23 k 0.65 0.95 l 12.35 ref m 5 10 n 0.13 0.17 p 0.325 bsc q 0 7 r 0.13 0.30 s 16.95 17.45 t 0.13 --- u 0 --- v 16.95 17.45 w 0.35 0.45 x 1.6 ref s a-b m 0.20 d s c s a-b m 0.20 d s h 0.05 a-b datum plane -h- s a-b m 0.20 d s c s a-b m 0.20 d s c

how to reach us: usa/europe/locations not listed: motorola literature distribution p.o. box 5405 denver, colorado 80217 1-800-521-6274 or 480-768-2130 japan: motorola japan ltd. sps, technical information center 3-20-1, minami-azabu, minato-ku tokyo 106-8573, japan 81-3-3440-3569 asia/pacific: motorola semiconductors h.k. ltd. silicon harbour centre 2 dai king street tai po industrial estate tai po, n.t., hong kong 852-26668334 home page: http://motorola.com/semiconductors m68hc12b rev. 9 6/2004 information in this document is provided solely to enable system and software implementers to use motorola products. there are no express or implied copyright licenses granted hereunder to design or fabricate any integrated circuits or integrated circuits based on the information in this document. motorola reserves the right to make changes without further notice to any products herein. motorola makes no warranty, representation or guarantee regarding the suitability of its products for any particular purpose, nor does motorola assume any liability arising out of the application or use of any prod uct or circuit, and specifically disclaims any and all liability , including without limitation consequential or incidental damages. ?typical? parameters that may be provided in motorola data sheets and/or specifications can and do vary in different applications and actual performance may vary over time. all operating parameters, including ?typicals?, must be validated for each customer application by customer?s technical experts. motorola does not convey any license under its patent rights nor the rights of others. motorola products are not designed, intended, or authorized for use as components in systems intended for surgical implant into the body, or other applications intended to support or sustain life, or for any other application in which the failure of the motorola product could create a situation where personal injury or death may occur. should buyer purchase or use motorola products for any such unintended or unauthorized application, buyer shall indemnify and hold motorola and its officers, employees, subsidiaries, affiliates, and distributors harmless against all claims, costs, damages, and expenses, and reasonable attorney fees arising out of, directly or indirectly, any claim of personal injury or death associated with such unintended or unauthorized use, even if such claim alleges that motorola was negligent regarding the design or manufacture of the part. motorola and the stylized m logo are registered in the us patent and trademark office. all other product or service names are the property of their respective owners. motorola, inc. is an equal opportunity/affirmative action employer. ? motorola inc. 2004


▲Up To Search▲   

 
Price & Availability of MC68HC12BE32VFU8

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X